1
0
mirror of synced 2025-02-13 17:12:39 +01:00

fix: Some shortcuts not working correctly on macOS

This commit is contained in:
WerWolv 2025-02-06 15:58:18 +01:00
parent f67b78bd91
commit 930d2b4280
3 changed files with 17 additions and 4 deletions

View File

@ -135,6 +135,8 @@ namespace hex {
*/
static void processGlobals(bool ctrl, bool alt, bool shift, bool super, u32 keyCode);
static void runShortcut(const Shortcut &shortcut, const View *view = nullptr);
/**
* @brief Clear all shortcuts
*/

View File

@ -342,12 +342,19 @@ namespace hex {
}
}
void ShortcutManager::runShortcut(const Shortcut &shortcut, const View *view) {
if (view == nullptr)
processShortcut(shortcut, s_globalShortcuts);
else
processShortcut(shortcut, view->m_shortcuts);
}
void ShortcutManager::process(const View *currentView, bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode) {
const Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, focused, keyCode);
if (keyCode != 0)
s_prevShortcut = Shortcut(pressedShortcut.getKeys());
processShortcut(pressedShortcut, currentView->m_shortcuts);
runShortcut(pressedShortcut, currentView);
}
void ShortcutManager::processGlobals(bool ctrl, bool alt, bool shift, bool super, u32 keyCode) {
@ -355,7 +362,7 @@ namespace hex {
if (keyCode != 0)
s_prevShortcut = Shortcut(pressedShortcut.getKeys());
processShortcut(pressedShortcut, s_globalShortcuts);
runShortcut(pressedShortcut);
}
std::optional<UnlocalizedString> ShortcutManager::getLastActivatedMenu() {

View File

@ -48,8 +48,12 @@ namespace hex::plugin::builtin {
callback();
}
} else if (menuItems.size() == 1) {
if (menu::menuItemEx(Lang(name), icon, shortcut, selectedCallback(), enabledCallback() && (view == nullptr || view->isFocused())))
callback();
if (menu::menuItemEx(Lang(name), icon, shortcut, selectedCallback(), enabledCallback())) {
if (shortcut == Shortcut::None)
callback();
else
ShortcutManager::runShortcut(shortcut, view);
}
} else {
bool isSubmenu = (menuItems.begin() + 1)->get() == ContentRegistry::Interface::impl::SubMenuValue;