Re: [Fxruby-users] makePositionVisible() fails in FXList, FXTreeList
Status: Inactive
Brought to you by:
lyle
From: jeroen <je...@fo...> - 2004-03-08 14:14:57
|
On Sunday 07 March 2004 10:21 pm, David L Hawley wrote: > Hi, > > I'm new to Ruby, Fox and this list. Am enjoying both Ruby and FXRuby, > although I'm having trouble figuring out how to do things. My application > is sort of like an RS-232 terminal (similar to Procomm). I'm using the > SerialPort module, which more or less works. It fails with addInput() - > the callback is called immediatly which causes a few problems to say the > least. Using addTimeout is a work around for now. > > My big problem now is that I can't seem to get makePositionVisible() to > work in both in FXList and FXTreeList. I've tried the index and item > version in FXList, item in FXTreeList. In both cases, the list scrolls to > the first element in the list. I can use FXText to display my data, and > there makePositionVisible() works. However, I'd rather have lines as > items... > > I'm trying to log events in the lists, and would like the list to scroll > up to display the most recent. > > my append code looks like this: > if USE_TREE > item= @cmdOutput.addItemLast(nil, text) > @cmdOutput.makeItemVisible(item) # list scrolls to first item > elsif USE_TXT_LIST > ix= @cmdOutput.appendItem(item= FXListItem.new(text)) > @cmdOutput.makeItemVisible(item) # list scrolls to first item > OR > @cmdOutput.makeItemVisible(ix) # list scrolls to first item > else > @cmdOutput.appendText(text) > @cmdOutput.makePositionVisible(@cmdOutput.text.length) # srolls to > put last line at bottom where I want > end > > Any ideas? The thing to remember is that makeItemVisible() can't work until the item sizes have been determined. The widget's contents are measured AFTER create() has been called, and AFTER a layout() has been performed. So, if you've just added an item, make sure the item is created, and then call layout() on the widget to force a size-computation. Now makeItemVisible() knows all the information to do its thing. Hope this helps, Jeroen -- +----------------------------------------------------------------------------+ | Copyright (C) 23:50 12/11/2003 Jeroen van der Zijp. All Rights Reserved. | +----------------------------------------------------------------------------+ |