summaryrefslogtreecommitdiff
path: root/src/Fl_Menu.cxx
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2024-10-06 12:19:54 -0500
committerGitHub <noreply@github.com>2024-10-06 19:19:54 +0200
commit5c6ec56b33d9eb5a9261eb72128d86f8e6ff5305 (patch)
treeb012a52280f23dbbec241a5e7d6af6d52ee08743 /src/Fl_Menu.cxx
parent6e3b64425e2b6345a4ba1d14c3c88f85bfc7f1a0 (diff)
Submenus with no callback enter their submenu instead of closing the whole menu (#1043)
Thanks for those nice changes.
Diffstat (limited to 'src/Fl_Menu.cxx')
-rw-r--r--src/Fl_Menu.cxx11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx
index effaafd9c..6332673da 100644
--- a/src/Fl_Menu.cxx
+++ b/src/Fl_Menu.cxx
@@ -824,6 +824,7 @@ int menuwindow::handle_part1(int e) {
}
return 1;
case FL_Right:
+ RIGHT:
if (pp.menubar && (pp.menu_number<=0 || (pp.menu_number == pp.nummenus-1)))
forward(0);
else if (pp.menu_number < pp.nummenus-1) forward(pp.menu_number+1);
@@ -836,6 +837,11 @@ int menuwindow::handle_part1(int e) {
case FL_Enter:
case FL_KP_Enter:
case ' ':
+ // if the current item is a submenu with no callback,
+ // simulate FL_Right to enter the submenu
+ if (pp.current_item && (!pp.menubar || pp.menu_number > 0) &&
+ pp.current_item->activevisible() && pp.current_item->submenu() && !pp.current_item->callback_)
+ goto RIGHT;
pp.state = DONE_STATE;
return 1;
case FL_Escape:
@@ -924,8 +930,9 @@ int menuwindow::handle_part1(int e) {
pp.p[pp.menu_number]->redraw();
} else
#endif
- // do nothing if they try to pick inactive items
- if (!pp.current_item || pp.current_item->activevisible())
+ // do nothing if they try to pick an inactive item, or a submenu with no callback
+ if (!pp.current_item || (pp.current_item->activevisible() &&
+ (!pp.current_item->submenu() || pp.current_item->callback_ || (pp.menubar && pp.menu_number <= 0))))
pp.state = DONE_STATE;
}
return 1;