ctlPrefWindow // Format tweaks & remove useless expressions.

This commit is contained in:
ShikiSuen 2022-03-15 21:09:10 +08:00
parent f0ca99c0cd
commit f307bc4f85
1 changed files with 18 additions and 20 deletions

View File

@ -211,27 +211,25 @@ extension RangeReplaceableCollection where Element: Hashable {
@IBAction func changeSelectionKeyAction(_ sender: Any) { @IBAction func changeSelectionKeyAction(_ sender: Any) {
guard let keys = (sender as AnyObject).stringValue?.trimmingCharacters(in: .whitespacesAndNewlines).charDeDuplicate else { guard let keys = (sender as AnyObject).stringValue?.trimmingCharacters(in: .whitespacesAndNewlines).charDeDuplicate else {
return return
}
do {
try Preferences.validate(candidateKeys: keys)
Preferences.candidateKeys = keys
selectionKeyComboBox.stringValue = Preferences.candidateKeys
}
catch Preferences.CandidateKeyError.empty {
selectionKeyComboBox.stringValue = Preferences.candidateKeys
}
catch {
if let window = window {
let alert = NSAlert(error: error)
alert.beginSheetModal(for: window) { response in
self.selectionKeyComboBox.stringValue = Preferences.candidateKeys
} }
do { clsSFX.beep()
try Preferences.validate(candidateKeys: keys) }
Preferences.candidateKeys = keys }
}
catch Preferences.CandidateKeyError.empty {
selectionKeyComboBox.stringValue = Preferences.candidateKeys
}
catch {
if let window = window {
let alert = NSAlert(error: error)
alert.beginSheetModal(for: window) { response in
self.selectionKeyComboBox.stringValue = Preferences.candidateKeys
}
clsSFX.beep()
}
}
selectionKeyComboBox.stringValue = keys
Preferences.candidateKeys = keys
} }
} }