mirror of https://github.com/fltk/fltk
Submenus with no callback enter their submenu instead of closing the whole menu
This commit is contained in:
parent
f151ecb87b
commit
882bae4e2f
|
@ -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)) {
|
||||
|
|
|
@ -821,6 +821,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);
|
||||
|
@ -833,6 +834,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:
|
||||
|
@ -922,8 +928,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;
|
||||
|
|
Loading…
Reference in New Issue