Skip to content

Commit

Permalink
fix: activate shortcuts without updating their userdefaults
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed May 5, 2020
1 parent b3ba94f commit 5b36ac3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ui/preferences-window/LabelAndControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 7 additions & 1 deletion src/ui/preferences-window/tabs/GeneralTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: "") })
Expand Down

0 comments on commit 5b36ac3

Please sign in to comment.