diff --git a/alt-tab-macos/logic/Keyboard.swift b/alt-tab-macos/logic/Keyboard.swift index b354283b..1ca60332 100644 --- a/alt-tab-macos/logic/Keyboard.swift +++ b/alt-tab-macos/logic/Keyboard.swift @@ -2,10 +2,10 @@ import Cocoa // Apple doesn't provide an enum for this, strangely enum KeyCode: UInt16 { + case tab = 48 case escape = 53 case command = 55 case capsLock = 57 - case tab = 58 case control = 59 case function = 63 case leftArrow = 123 diff --git a/alt-tab-macos/logic/Preferences.swift b/alt-tab-macos/logic/Preferences.swift index f32bc2aa..6862711c 100644 --- a/alt-tab-macos/logic/Preferences.swift +++ b/alt-tab-macos/logic/Preferences.swift @@ -3,12 +3,12 @@ import Cocoa class Preferences { static var defaults: [String: String] = [ - "version": "1", // bump this anytime the dictionary is changed - "maxScreenUsage": "0.8", + "version": "2", // bump this anytime the dictionary is changed + "maxScreenUsage": "80", "maxThumbnailsPerRow": "4", "iconSize": "32", "fontHeight": "15", - "tabKey": String(KeyCode.tab.rawValue), + "tabKeyCode": String(KeyCode.tab.rawValue), "metaKey": metaKeyMacro.macros[0].label, "windowDisplayDelay": "0", "theme": themeMacro.macros[0].label @@ -67,7 +67,7 @@ class Preferences { static func updateAndValidateFromString(_ valueName: String, _ value: String) throws { switch valueName { case "maxScreenUsage": - maxScreenUsage = try CGFloat(value).orThrow() + maxScreenUsage = try CGFloat(CGFloat(value).orThrow() / 100) case "maxThumbnailsPerRow": maxThumbnailsPerRow = try CGFloat(value).orThrow() case "iconSize": @@ -75,7 +75,7 @@ class Preferences { case "fontHeight": fontHeight = try CGFloat(value).orThrow() font = NSFont.systemFont(ofSize: fontHeight!) - case "tabKey": + case "tabKeyCode": tabKeyCode = try UInt16(value).orThrow() case "metaKey": let p = try metaKeyMacro.labelToMacro[value].orThrow() diff --git a/alt-tab-macos/ui/PreferencesPanel.swift b/alt-tab-macos/ui/PreferencesPanel.swift index 033642e7..8a977f58 100644 --- a/alt-tab-macos/ui/PreferencesPanel.swift +++ b/alt-tab-macos/ui/PreferencesPanel.swift @@ -11,7 +11,7 @@ class PreferencesPanel: NSPanel, NSTextViewDelegate { var iconSize: NSTextView? var fontHeight: NSTextView? var interItemPadding: NSTextView? - var tabKey: NSTextView? + var tabKeyCode: NSTextView? var windowDisplayDelay: NSTextView? var metaKey: NSPopUpButton? var theme: NSPopUpButton? @@ -28,7 +28,7 @@ class PreferencesPanel: NSPanel, NSTextViewDelegate { [ makeLabelWithDropdown(\PreferencesPanel.theme, "Main window theme", "theme", Preferences.themeMacro.labels), makeLabelWithDropdown(\PreferencesPanel.metaKey, "Meta key to activate the app", "metaKey", Preferences.metaKeyMacro.labels), - makeLabelWithInput(\PreferencesPanel.tabKey, "Tab key (NSEvent.keyCode)", "tabKey"), + makeLabelWithInput(\PreferencesPanel.tabKeyCode, "Tab key (NSEvent.keyCode)", "tabKeyCode"), makeLabelWithInput(\PreferencesPanel.maxScreenUsage, "Max window size (screen %)", "maxScreenUsage"), makeLabelWithInput(\PreferencesPanel.maxThumbnailsPerRow, "Max thumbnails per row", "maxThumbnailsPerRow"), makeLabelWithInput(\PreferencesPanel.iconSize, "Apps icon size (px)", "iconSize"),