From 40b604c6e4b9cf4e9c355b4fdcf25e8cf7ebc77d Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 29 Dec 2025 19:31:54 +0100 Subject: [PATCH] fix: ImGui-internal shortcuts not working correctly with native macOS menu bar enabled (cherry picked from commit f0f6a22391672d3a1c0a97281b008acbc2e1d7dd) --- lib/libimhex/source/api/shortcut_manager.cpp | 11 ++++++----- plugins/builtin/source/content/window_decoration.cpp | 6 +++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/libimhex/source/api/shortcut_manager.cpp b/lib/libimhex/source/api/shortcut_manager.cpp index 353860852..ca5b69ebe 100644 --- a/lib/libimhex/source/api/shortcut_manager.cpp +++ b/lib/libimhex/source/api/shortcut_manager.cpp @@ -329,12 +329,13 @@ namespace hex { if (ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId)) return true; - const bool currentlyTyping = ImGui::GetIO().WantTextInput; - - auto it = shortcuts.find(shortcut + AllowWhileTyping); - if (!currentlyTyping && it == shortcuts.end()) { + auto it = shortcuts.end(); + if (ImGui::GetIO().WantTextInput) { + it = shortcuts.find(shortcut + AllowWhileTyping); + } else { + it = shortcuts.find(shortcut); if (it == shortcuts.end()) - it = shortcuts.find(shortcut); + it = shortcuts.find(shortcut + AllowWhileTyping); } if (it != shortcuts.end()) { diff --git a/plugins/builtin/source/content/window_decoration.cpp b/plugins/builtin/source/content/window_decoration.cpp index 69125f18e..466054904 100644 --- a/plugins/builtin/source/content/window_decoration.cpp +++ b/plugins/builtin/source/content/window_decoration.cpp @@ -70,7 +70,11 @@ namespace hex::plugin::builtin { callback(); } } else if (menuItems.size() == 1) { - if (menu::menuItemEx(Lang(name), icon, shortcut, selectedCallback(), enabledCallback())) { + bool enabled = enabledCallback(); + if (!shortcut.has(AllowWhileTyping) && ImGui::GetIO().WantTextInput) + enabled = false; + + if (menu::menuItemEx(Lang(name), icon, shortcut, selectedCallback(), enabled)) { if (shortcut == Shortcut::None) callback(); else {