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
This commit is contained in:
parent
9bfbc26899
commit
797d78d86c
@ -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 $".
|
||||
//
|
||||
|
@ -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 $".
|
||||
//
|
||||
|
@ -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 $".
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user