diff options
| author | Bill Spitzak <spitzak@gmail.com> | 2000-07-30 00:31:44 +0000 |
|---|---|---|
| committer | Bill Spitzak <spitzak@gmail.com> | 2000-07-30 00:31:44 +0000 |
| commit | 797d78d86c4ce3bc830b5fcd30ac5a6c73d0ee42 (patch) | |
| tree | 0b2e562b1316fc5a2bcaace85f1a1857e9a3f94d | |
| parent | 9bfbc26899e98167ba6874acd2067c5d405ee93c (diff) | |
Shortcuts for "buttons" in a Fl_Menu_Bar work again.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1267 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/Fl_Menu.cxx | 34 | ||||
| -rw-r--r-- | src/Fl_Menu_Bar.cxx | 13 | ||||
| -rw-r--r-- | test/menubar.cxx | 6 |
3 files changed, 30 insertions, 23 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index cfb2943c6..bfcb0f887 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Menu.cxx,v 1.18.2.9 2000/06/29 07:23:56 spitzak Exp $" +// "$Id: Fl_Menu.cxx,v 1.18.2.10 2000/07/30 00:31:44 spitzak Exp $" // // Menu code for the Fast Light Tool Kit (FLTK). // @@ -384,18 +384,6 @@ int menuwindow::titlex(int i) { return x; } -// match shortcuts & label shortcuts, don't search submenus: -// returns menu item and index -const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip) const { - const Fl_Menu_Item* m1 = this; - for (int ii = 0; m1 && m1->text; m1 = m1->next(1), ii++) { - if (m1->activevisible() && - (Fl::test_shortcut(m1->shortcut_) - || Fl_Widget::test_shortcut(m1->text))) {if (ip) *ip=ii; return m1;} - } - return 0; -} - //////////////////////////////////////////////////////////////// // Fl_Menu_Item::popup(...) @@ -717,6 +705,24 @@ Fl_Menu_Item::popup( return pulldown(X, Y, 0, 0, picked, button, title ? &dummy : 0); } +// Search only the top level menu for a shortcut. Either &x in the +// label or the shortcut fields are used: +const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip) const { + const Fl_Menu_Item* m = this; + if (m) for (int ii = 0; m->text; m = m->next(), ii++) { + if (m->activevisible()) { + if (Fl::test_shortcut(m->shortcut_) + || Fl_Widget::test_shortcut(m->text)) { + if (ip) *ip=ii; + return m; + } + } + } + return 0; +} + +// Recursive search of all submenus for anything with this key as a +// shortcut. Only uses the shortcut field, ignores &x in the labels: const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const { const Fl_Menu_Item* m = this; const Fl_Menu_Item* ret = 0; @@ -737,5 +743,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const { } // -// End of "$Id: Fl_Menu.cxx,v 1.18.2.9 2000/06/29 07:23:56 spitzak Exp $". +// End of "$Id: Fl_Menu.cxx,v 1.18.2.10 2000/07/30 00:31:44 spitzak Exp $". // diff --git a/src/Fl_Menu_Bar.cxx b/src/Fl_Menu_Bar.cxx index 82d2efb89..886467ef7 100644 --- a/src/Fl_Menu_Bar.cxx +++ b/src/Fl_Menu_Bar.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Menu_Bar.cxx,v 1.7.2.3 2000/07/11 05:36:39 spitzak Exp $" +// "$Id: Fl_Menu_Bar.cxx,v 1.7.2.4 2000/07/30 00:31:44 spitzak Exp $" // // Menu bar widget for the Fast Light Tool Kit (FLTK). // @@ -50,14 +50,15 @@ int Fl_Menu_Bar::handle(int event) { picked(v); return 1; case FL_SHORTCUT: - if (visible_r()) {if ((v = menu()->find_shortcut())) goto J1;} - v = menu()->test_shortcut(); - if (v) {picked(v); return 1;} - return 0; + if (visible_r()) { + v = menu()->find_shortcut(); + if (v && v->submenu()) goto J1; + } + return test_shortcut() != 0; } return 0; } // -// End of "$Id: Fl_Menu_Bar.cxx,v 1.7.2.3 2000/07/11 05:36:39 spitzak Exp $". +// End of "$Id: Fl_Menu_Bar.cxx,v 1.7.2.4 2000/07/30 00:31:44 spitzak Exp $". // diff --git a/test/menubar.cxx b/test/menubar.cxx index deca25ea5..99195e37c 100644 --- a/test/menubar.cxx +++ b/test/menubar.cxx @@ -1,5 +1,5 @@ // -// "$Id: menubar.cxx,v 1.6.2.6 2000/07/11 05:36:39 spitzak Exp $" +// "$Id: menubar.cxx,v 1.6.2.7 2000/07/30 00:31:44 spitzak Exp $" // // Menubar test program for the Fast Light Tool Kit (FLTK). // @@ -145,7 +145,7 @@ Fl_Menu_Item menutable[] = { {"A very long menu item"}, {0}, {"&Huge", 0, 0, (void*)hugemenu, FL_SUBMENU_POINTER}, - {"button",0, 0, 0, FL_MENU_TOGGLE}, + {"button",FL_F+4, 0, 0, FL_MENU_TOGGLE}, {0} }; @@ -216,5 +216,5 @@ int main(int argc, char **argv) { } // -// End of "$Id: menubar.cxx,v 1.6.2.6 2000/07/11 05:36:39 spitzak Exp $". +// End of "$Id: menubar.cxx,v 1.6.2.7 2000/07/30 00:31:44 spitzak Exp $". // |
