Hi, On Tue, Apr 01, 2008 at 06:46:34PM +0200, Johannes Hofmann wrote:
Hello,
On Tue, Apr 01, 2008 at 03:41:29AM +0000, corvid wrote:
I wrote:
I wrote:
Does anybody remember whether the add() call was for some reason that I haven't noticed?
I don't think it is necessary as long as Group::current() is NULL (no begin() without end ()). Otherwise the popup menu would be added to Group::current() - whatever that is.
I may have added it long ago to "make it work".
Hmm. On my various (generally quite simple) pages, it works fine with images or tables or lists or whatever. On some pages out in the wider world, though, it gets really confused. I had thought fltk was getting a mouse event and just going up the fltk widget tree to figure out x,y. That is, just Main -> UI. I guess not.
This makes my problem go away:
diff -pur dw2/dw/fltkui.cc dw2-cur/dw/fltkui.cc --- dw2/dw/fltkui.cc 2008-02-05 03:14:22.000000000 +0000 +++ dw2-cur/dw/fltkui.cc 2008-04-01 03:24:56.000000000 +0000 @@ -972,6 +972,7 @@ template <class I> void FltkSelectionRes } widgetStack->widget->set_item (pos, widgetStack->stack->size ()); } + widgetStack->stack->getTop()->getTypedValue()->end (); } }
Jeremy, does that seem all right?
Yes, that is right! I would go even further and remove all begin() calls. They are evil - at least if the matching end () is not immediately following. In your case the unmatched end () caused the popup menu to become a child of some Select-widget that happened to be on the page!
From some time Johannes has been warning us about begin-end pairs. I agree with him, they bring side effects (just as the above mentioned one), so removing them favouring explicit add() calls is preferred. Unless they cleanly match each other in the same function, without calling other widget-constructing functions in the middle.
I would propose the attached patch to fltkui.cc that replaces all begin () calls with direct add () calls.
Committed.
Then your proposed removal of the ((Group *)bw->ui)->add(pm) calls (also attached) seems to work fine. It also makes the annoying redraws when opening a popup menu go away!
Committed. -- Cheers Jorge.-