From 5c6ec56b33d9eb5a9261eb72128d86f8e6ff5305 Mon Sep 17 00:00:00 2001 From: dannye <33dannye@gmail.com> Date: Sun, 6 Oct 2024 12:19:54 -0500 Subject: Submenus with no callback enter their submenu instead of closing the whole menu (#1043) Thanks for those nice changes. --- src/Fl_Menu.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Fl_Menu.cxx') 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; -- cgit v1.2.3