fix: activate shortcuts without updating their userdefaults

This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-05-06 04:34:58 +09:00
1 parent b3ba94fe0f
commit 6aad3e7724
2 files changed
+8 -2

No files matched your search

@@ -11,7 +11,7 @@ class LabelAndControl: NSObject {
static func makeLabelWithRecorder(_ labelText: String, _ rawName: String, _ shortcutString: String, _ clearable: Bool = true, labelPosition: LabelPosition = .leftWithSeparator) -> [NSView] {
let input = CustomRecorderControl(shortcutString, clearable)
let views = makeLabelWithProvidedControl(labelText, rawName, input, labelPosition: labelPosition, extraAction: GeneralTab.shortcutChangedCallback)
input.sendAction(input.action, to: input.target)
GeneralTab.shortcutChangedCallback(input)
return views
}
@@ -104,7 +104,13 @@ class GeneralTab: NSViewController, PreferencePane {
let controlId = sender.identifier!.rawValue
if controlId == "holdShortcut" {
addShortcut(.up, Shortcut(keyEquivalent: Preferences.holdShortcut)!, controlId)
shortcutsDependentOnHoldShortcut.forEach { $0.sendAction($0.action, to: $0.target) }
shortcutsDependentOnHoldShortcut.forEach {
if $0.identifier!.rawValue == "arrowKeysEnabled" {
GeneralTab.arrowKeysEnabledCallback($0)
} else {
GeneralTab.shortcutChangedCallback($0)
}
}
} else {
// remove the holdShortcut character in case they also use it in the other shortcuts
let newValue = Preferences.holdShortcut.reduce((sender as! RecorderControl).stringValue, { $0.replacingOccurrences(of: String($1), with: "") })