fix: Some shortcuts not working correctly on macOS
This commit is contained in:
parent
f67b78bd91
commit
930d2b4280
@ -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
|
||||
*/
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user