feat: avoid disabling native command-tab (closes #834)
This commit is contained in:
1 parent
5390e411cc
commit
fb51c5d14b
2 files changed
+12
-8
No files matched your search
@@ -21,13 +21,11 @@ class KeyboardEvents {
|
||||
static func addGlobalShortcut(_ controlId: String, _ shortcut: Shortcut) {
|
||||
addGlobalHandlerIfNeeded(shortcut)
|
||||
registerHotKeyIfNeeded(controlId, shortcut)
|
||||
toggleNativeCommandTabIfNeeded(shortcut, false)
|
||||
}
|
||||
|
||||
static func removeGlobalShortcut(_ controlId: String, _ shortcut: Shortcut) {
|
||||
unregisterHotKeyIfNeeded(controlId, shortcut)
|
||||
removeHandlerIfNeeded()
|
||||
toggleNativeCommandTabIfNeeded(shortcut, true)
|
||||
}
|
||||
|
||||
private static func unregisterHotKeyIfNeeded(_ controlId: String, _ shortcut: Shortcut) {
|
||||
@@ -63,12 +61,6 @@ class KeyboardEvents {
|
||||
}
|
||||
}
|
||||
|
||||
private static func toggleNativeCommandTabIfNeeded(_ shortcut: Shortcut, _ enabled: Bool) {
|
||||
if (shortcut.carbonModifierFlags == cmdKey || shortcut.carbonModifierFlags == (cmdKey | shiftKey)) && shortcut.carbonKeyCode == kVK_Tab {
|
||||
setNativeCommandTabEnabled(enabled)
|
||||
}
|
||||
}
|
||||
|
||||
static func addEventHandlers() {
|
||||
addLocalMonitorForKeyDownAndKeyUp()
|
||||
addCgEventTapForModifierFlags()
|
||||
|
||||
@@ -110,6 +110,18 @@ class ControlsTab {
|
||||
if scope == .global {
|
||||
KeyboardEvents.addGlobalShortcut(controlId, atShortcut.shortcut)
|
||||
}
|
||||
toggleNativeCommandTabIfNeeded()
|
||||
}
|
||||
|
||||
private static func toggleNativeCommandTabIfNeeded() {
|
||||
for atShortcut in shortcuts.values {
|
||||
let shortcut = atShortcut.shortcut
|
||||
if (shortcut.carbonModifierFlags == cmdKey || shortcut.carbonModifierFlags == (cmdKey | shiftKey)) && shortcut.carbonKeyCode == kVK_Tab {
|
||||
setNativeCommandTabEnabled(false)
|
||||
return
|
||||
}
|
||||
}
|
||||
setNativeCommandTabEnabled(true)
|
||||
}
|
||||
|
||||
@objc static func shortcutChangedCallback(_ sender: NSControl) {
|
||||
|
||||
Reference in new issue
Block a user