On 09/27/12 13:08, Eric Sokolowsky wrote: >> On 09/27/12 10:47, Eric Sokolowsky wrote: >>> I'm using FLTK 1.3.0 and have a list of widgets in a Fl_Pack. This Fl_Pack >>> is inside a Fl_Scroll. When I add a new item to the Fl_Pack I want the item >>> to be visible right away, scrolling if necessary. Is there a way to do this >>> easily, or do I have to figure out where the new item is and if offscreen >>> figure out how much to adjust the scrollbar. I tried using the latter >>> method but the screen does not update right after the item is inserted >>> until I move the cursor again, even if I put the code to update the >>> scrollbar position at the beginning of my Fl_Scroll's draw() function. >> >> When you add the item to the pack, position the scroller, >> then call the parent window's redraw() method, eg. >> scroll->window()->redraw(); >> and see if that does it. >> > > I tried that and it didn't seem to work. I still have to move the mouse after > dropping the new item in order to see the scroll position change. Any other > suggestions? Thanks for the help.
Hmm, this sounds familiar.. If Fl_Scroll is like some other widgets, I /think/ the scroll position might be calculated during actual drawing of the widget.. so you probably have to cause a redraw event once just for the positions to be calculated internally for the widget, then again once those calculations have been made. So instead of just calling redraw() once, first try this: scroll->window()->redraw(); Fl::wait(.10); scroll->window()->redraw(); This will cause two redraws, perhaps fixing the problem. If that doesn't work, you /might/ have to put your scroll position code just after the Fl::wait(.10), as after that the scroll widget should have redrawn itself and recalculated its internals. But try the simple thing first, just the above extra two lines. _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk