diff options
| author | Matthias Melcher <github@matthiasm.com> | 2024-12-09 19:57:23 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2024-12-09 19:57:23 +0100 |
| commit | 05ee86fe5772643b8994eecba83c623884eae7c4 (patch) | |
| tree | ac0f8d6dd8d2615632193771fca61727cfe26a4b /src/Fl_Menu.cxx | |
| parent | 5af4108169622f0698913150d357af35d8e832b0 (diff) | |
Fixes triggering callback for inactive menu items (#1159)
The old code would trigger a callback when hovering the
mouse of an inactive item and pressing Return.
Diffstat (limited to 'src/Fl_Menu.cxx')
| -rw-r--r-- | src/Fl_Menu.cxx | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index 4cae09f5d..7350f4af5 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -841,10 +841,19 @@ int menuwindow::handle_part1(int e) { 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_) + if ( pp.current_item + && (!pp.menubar || pp.menu_number > 0) + && pp.current_item->activevisible() + && pp.current_item->submenu() + && !pp.current_item->callback_) + { goto RIGHT; - if (pp.current_item && pp.current_item->activevisible()) pp.state = DONE_STATE; + } + // Ignore keypresses over inactive items, mark KEYBOARD event as used. + if (pp.current_item && !pp.current_item->activevisible()) + return 1; + // Mark the menu 'done' which will trigger the callback + pp.state = DONE_STATE; return 1; case FL_Escape: setitem(0, -1, 0); |
