DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New] Link: http://www.fltk.org/str.php?L2950 Version: 1.3-feature Currently clicking on ANY menu item causes the whole menu to close - which is sometimes annoying, even if the item is: 1) A submenu. Usually submenu is just an entry point and "mouse hovering" opens the submenu automatically, an accidental clicking on this entry point should not close the whole menu. "Not closing" the menu would also indicate that no action was performed and choosing particular submenu-item is required to invoke an action 2) A checkbox or radio box. If menu item group is set of check-boxes and user wants to change a few settings at the same time, he/she needs to reopen the menu for each single item change. Sometimes user re-opens the menu even for single checkbox just to visually confirm that the state was changed. In such a case they expect that menu closes only if you either hit "Esc" or click menu-opening widget (menu-bar or menu-button) Following is an implementation (just included in this message for simplicity) to give the developper fine control. It is very conservative (does not change current behaviour) but adds the programmer possibility to control when the items close the menus. The API consists of two additional functions, they are implementad as "static" of Fl_Menu_Item namespace: class Fl_Menu_Item { ... public: static void no_close_flags(int f){no_close_flags_ = f;} static int no_close_flags(){return no_close_flags_;} private: static int no_close_flags_; }; The user can globally change how when the items do not close the menus - ie at the beginning of the program: Fl_Menu_Item::no_close_flags(FL_MENU_TOGGLE|FL_MENU_RADIO|FL_SUBMENU|FL_SUBMENU_POINTER); User can also control the items individually like: #define FL_MENU_NO_CLOSE 0x200 Fl_Menu_Item::no_close_flags(FL_MENU_NO_CLOSE); and then OR this custom flag to the other flags of particular menu items. Implementation: 1) In file "Fl_Menu_Item.H" define the functions as rescribed above 2) In file "Fl_Menu.cxx" change code in function menuwindow::early_hide_handle(int e), line approx. 783: #if 1 // uncommenting - makes defined items leave the menu up const Fl_Menu_Item* m = pp.current_item; if (m && button && (m->flags & Fl_Menu_Item::no_close_flags())) { ((Fl_Menu_*)button)->picked(m); pp.p[pp.menu_number]->redraw(); } else #endif 3) In file "Fl_Menu_.cxx" implement int Fl_Menu_Item::no_close_flags_ = 0; and change code in function Fl_Menu_::picked() from line approx 271: if (value_ && value_->callback_) value_->do_callback((Fl_Widget*)this); else if(!(value_->flags & Fl_Menu_Item::no_close_flags()& (FL_SUBMENU | FL_SUBMENU_POINTER))) // do not execute parent's widget (common) callback if there is no direct menuitem callback assigned // and menu is not closed and isem is just a submenu (no valid item picked) do_callback(); } The code was tested and everything works as expected. Roman Link: http://www.fltk.org/str.php?L2950 Version: 1.3-feature _______________________________________________ fltk-dev mailing list fltk-dev@easysw.com http://lists.easysw.com/mailman/listinfo/fltk-dev