Submenus with no callback enter their submenu instead of closing the whole menu (#1043)

Thanks for those nice changes.
This commit is contained in:
dannye 2024-10-06 12:19:54 -05:00 committed by GitHub
parent 6e3b64425e
commit 5c6ec56b33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -378,7 +378,9 @@ static void createSubMenu( NSMenu *mh, pFl_Menu_Item &mm, const Fl_Menu_Item *m
mm = mm->next(0);
continue;
}
miCnt = [FLMenuItem addNewItem:mm menu:submenu action:selector];
miCnt = [FLMenuItem addNewItem:mm menu:submenu
action:( (mm->flags & (FL_SUBMENU+FL_SUBMENU_POINTER) && !mm->callback()) ? nil : selector)
];
setMenuFlags( submenu, miCnt, mm );
setMenuShortcut( submenu, miCnt, mm );
if (mitem && (mm->flags & FL_MENU_INACTIVE || mitem->flags & FL_MENU_INACTIVE)) {

View File

@ -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;