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".
This commit is contained in:
Campbell Barton 2021-01-28 10:39:12 +11:00
parent 37e60289c2
commit 198980693b
Notes: blender-bot 2023-02-13 22:38:46 +01:00
Referenced by issue #84931, Press and hold W key in edit mode makes menu appears and disappear fast
1 changed files with 11 additions and 2 deletions

View File

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