mirror of
https://github.com/lwouis/alt-tab-macos.git
synced 2026-05-24 11:20:36 +00:00
feat: avoid disabling native command-tab (closes #834)
This commit is contained in:
@@ -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