diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-01-28 02:39:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-01-28 02:50:47 +0300 |
commit | 198980693ba7b183f7d2a32a21b65338edfdeb10 (patch) | |
tree | ebcecd21ee761df36fdebb55c34fb0c3b648859d | |
parent | 37e60289c2099148dddc7fdd7a8855c2c0a97328 (diff) |
Fix T84931: Keys that open menus can also activate menu items
Disable key-accelerators for key-repeat events.
When a key was held it could open the menu and activate the menu
item associated with that key.
With the RMB select option: edit-meshes & edge-selection caused
holding W to open & activate "Edge Bevel Weight".
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 377e55e7299..50c5c27b5c1 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -9905,6 +9905,12 @@ static int ui_handle_menu_event(bContext *C, break; } + /* Only respond to explicit press to avoid the event that opened the menu + * activating an item when the key is held. */ + if (event->is_repeat) { + break; + } + if (event->alt) { act += 10; } @@ -9984,8 +9990,11 @@ static int ui_handle_menu_event(bContext *C, case EVT_XKEY: case EVT_YKEY: case EVT_ZKEY: { - if ((event->val == KM_PRESS || event->val == KM_DBL_CLICK) && - !IS_EVENT_MOD(event, shift, ctrl, oskey)) { + if (ELEM(event->val, KM_PRESS, KM_DBL_CLICK) && + !IS_EVENT_MOD(event, shift, ctrl, oskey) && + /* Only respond to explicit press to avoid the event that opened the menu + * activating an item when the key is held. */ + !event->is_repeat) { if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) { break; } |