From 180a27fdc91090db83aa0ece02502c2bdc7288e1 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 21 May 2023 10:28:55 +0200 Subject: [PATCH] fix: Local keybindings not working correctly --- lib/libimhex/source/api/keybinding.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/libimhex/source/api/keybinding.cpp b/lib/libimhex/source/api/keybinding.cpp index 3f16aaf6c..7b76d7baf 100644 --- a/lib/libimhex/source/api/keybinding.cpp +++ b/lib/libimhex/source/api/keybinding.cpp @@ -15,7 +15,7 @@ namespace hex { view->m_shortcuts.insert({ shortcut, callback }); } - static Shortcut getShortcut(bool ctrl, bool alt, bool shift, bool super, u32 keyCode) { + static Shortcut getShortcut(bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode) { Shortcut pressedShortcut; if (ctrl) @@ -26,6 +26,8 @@ namespace hex { pressedShortcut += SHIFT; if (super) pressedShortcut += SUPER; + if (focused) + pressedShortcut += CurrentView; pressedShortcut += static_cast(keyCode); @@ -33,14 +35,14 @@ namespace hex { } void ShortcutManager::process(const std::unique_ptr ¤tView, bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode) { - Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, keyCode); + Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, focused, keyCode); - if (focused && currentView->m_shortcuts.contains(pressedShortcut)) + if (currentView->m_shortcuts.contains(pressedShortcut)) currentView->m_shortcuts[pressedShortcut](); } void ShortcutManager::processGlobals(bool ctrl, bool alt, bool shift, bool super, u32 keyCode) { - Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, keyCode); + Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, false, keyCode); if (ShortcutManager::s_globalShortcuts.contains(pressedShortcut)) ShortcutManager::s_globalShortcuts[pressedShortcut]();