feat: allows more than one metaKeyCode
metaKeyCodes is now an array and is provided with both keycodes for option, control and command. This fixes two issues: - UI stayed open when the user did open it with the secondary metaKey keyCode (the UI got toggled by the modifierFlags check) and the user had to click the proper metaKeyCode to close it again - PC keyboards (all of them? i observed this on a Logitech K740) send the secondary keyCode for the command and option keys so the application did not work for this setup
This commit is contained in:
1 parent
479778662d
commit
7e21974ebf
2 files changed
+9
-9
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import Cocoa
|
||||
import Carbon.HIToolbox
|
||||
import Carbon.HIToolbox.Events
|
||||
|
||||
class Keyboard {
|
||||
static func listenToGlobalEvents(_ delegate: Application) {
|
||||
@@ -34,7 +34,7 @@ func keyboardHandler(_ cgEvent: CGEvent, _ delegate: Application) -> Unmanaged<C
|
||||
if let event = NSEvent(cgEvent: cgEvent) {
|
||||
let keyDown = event.type == .keyDown
|
||||
let isTab = event.keyCode == Preferences.tabKeyCode
|
||||
let isMeta = event.keyCode == Preferences.metaKeyCode
|
||||
let isMeta = Preferences.metaKeyCodes!.contains(event.keyCode)
|
||||
let isRightArrow = event.keyCode == kVK_RightArrow
|
||||
let isLeftArrow = event.keyCode == kVK_LeftArrow
|
||||
let isEscape = event.keyCode == kVK_Escape
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
import Cocoa
|
||||
import Carbon.HIToolbox
|
||||
import Carbon.HIToolbox.Events
|
||||
|
||||
class Preferences {
|
||||
static var defaults: [String: String] = [
|
||||
@@ -32,7 +32,7 @@ class Preferences {
|
||||
static var tabKeyCode: UInt16?
|
||||
static var highlightBorderColor: NSColor?
|
||||
static var highlightBackgroundColor: NSColor?
|
||||
static var metaKeyCode: UInt16?
|
||||
static var metaKeyCodes: [UInt16]?
|
||||
static var metaModifierFlag: NSEvent.ModifierFlags?
|
||||
static var windowDisplayDelay: DispatchTimeInterval?
|
||||
static var windowCornerRadius: CGFloat?
|
||||
@@ -41,10 +41,10 @@ class Preferences {
|
||||
MacroPreference(" macOS", (0, 5, 20, .clear, NSColor(red: 0, green: 0, blue: 0, alpha: 0.3))),
|
||||
MacroPreference("❖ Windows 10", (2, 0, 0, .white, .clear))
|
||||
])
|
||||
static var metaKeyMacro = MacroPreferenceHelper<(Int, NSEvent.ModifierFlags)>([
|
||||
MacroPreference("⌥ option", (kVK_Option, .option)),
|
||||
MacroPreference("⌃ control", (kVK_Control, .control)),
|
||||
MacroPreference("⌘ command", (kVK_Command, .command))
|
||||
static var metaKeyMacro = MacroPreferenceHelper<([Int], NSEvent.ModifierFlags)>([
|
||||
MacroPreference("⌥ option", ([kVK_Option, kVK_RightOption], .option)),
|
||||
MacroPreference("⌃ control", ([kVK_Control, kVK_RightControl], .control)),
|
||||
MacroPreference("⌘ command", ([kVK_Command, kVK_RightCommand], .command))
|
||||
])
|
||||
|
||||
private static let defaultsFile = fileFromPreferencesFolder("alt-tab-macos-defaults.json")
|
||||
@@ -78,7 +78,7 @@ class Preferences {
|
||||
tabKeyCode = try UInt16(value).orThrow()
|
||||
case "metaKey":
|
||||
let p = try metaKeyMacro.labelToMacro[value].orThrow()
|
||||
metaKeyCode = UInt16(p.preferences.0)
|
||||
metaKeyCodes = p.preferences.0.map { UInt16($0) }
|
||||
metaModifierFlag = p.preferences.1
|
||||
case "theme":
|
||||
let p = try themeMacro.labelToMacro[value].orThrow()
|
||||
|
||||
Reference in new issue
Block a user