From ba9417470e53efa3ca828f30295f3cea8ea5d29c Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Mon, 13 Jan 2025 19:14:12 +0100 Subject: [PATCH] Fix #126409: Allow Menu Accelerators for Toggles When menus (that are not type-to-search) open we add underlines to most items so they can be selected quickly. We currently don't do this for items that are toggles. This PR adds accelerators to toggles. Pull Request: https://projects.blender.org/blender/blender/pulls/132309 --- source/blender/editors/interface/interface.cc | 3 +++ source/blender/editors/interface/interface_handlers.cc | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 72fbca926ef..ff0304dd29c 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -1164,6 +1164,9 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) UI_BTYPE_MENU, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN, + UI_BTYPE_ICON_TOGGLE, + UI_BTYPE_ICON_TOGGLE_N, + /* For PIE-menus. */ UI_BTYPE_ROW) || (but->flag & UI_HIDDEN)) diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index bafd8f7df07..0a681b84498 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -11111,7 +11111,11 @@ static int ui_handle_menu_event(bContext *C, /* Accelerator keys that allow "pressing" a menu entry by pressing a single key. */ LISTBASE_FOREACH (uiBut *, but_iter, &block->buttons) { if (!(but_iter->flag & UI_BUT_DISABLED) && but_iter->menu_key == event->type) { - if (but_iter->type == UI_BTYPE_BUT) { + if (ELEM(but_iter->type, + UI_BTYPE_BUT, + UI_BTYPE_ICON_TOGGLE, + UI_BTYPE_ICON_TOGGLE_N)) + { UI_but_execute(C, region, but_iter); } else {