From e9154f59e65eb7a9e6149ac3fab5620a625ec8c8 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Thu, 29 Dec 2022 15:20:40 +0100 Subject: [PATCH] Menu: disable triggers when SetTriggerEnabled(false) is called Triggers are a way to trigger menu items by ressing one of the letters in their label. Normally that letter is underlined in the menu, but in Haiku this is disabled by default and can't be enabled due to the lack of a Menu preference (the code is there to draw the underline, still). The trigger for each item is either assigned manually (using SetTrigger) or automatically by the Interface Kit (picking a reasonable letter from the label). Triggers can be completly disabled at the menu level, however, in Haiku this only disables drawing the underlines, and does not actually disable the triggers, so items can still be invoked. This does not match what is said in the Be Book. This commit actually disables the triggers when SetTriggerEnabled(false) is called, making the keyboard available for other uses if needed. Possibly affected apps from a GitHub search on "SetTriggersEnabled": - BeCJK - 8dock - Some of Tracker menus with lots of items, for example X-Ray menus Change-Id: I1efa675b018fa524953c81e2dc2d456c28d6be8e Reviewed-on: https://review.haiku-os.org/c/haiku/+/5971 Reviewed-by: waddlesplash Tested-by: Commit checker robot --- src/kits/interface/Menu.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index eee774758f..2489be72bb 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -589,16 +589,18 @@ BMenu::KeyDown(const char* bytes, int32 numBytes) default: { - uint32 trigger = BUnicodeChar::FromUTF8(&bytes); + if (AreTriggersEnabled()) { + uint32 trigger = BUnicodeChar::FromUTF8(&bytes); - for (uint32 i = CountItems(); i-- > 0;) { - BMenuItem* item = ItemAt(i); - if (item->fTriggerIndex < 0 || item->fTrigger != trigger) - continue; + for (uint32 i = CountItems(); i-- > 0;) { + BMenuItem* item = ItemAt(i); + if (item->fTriggerIndex < 0 || item->fTrigger != trigger) + continue; - _InvokeItem(item); - _QuitTracking(false); - break; + _InvokeItem(item); + _QuitTracking(false); + break; + } } break; }