From 2a5f02601c91c81e4651079d8f0904e954a2d25d Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sat, 17 Jun 2023 21:37:44 +0800 Subject: [PATCH] PrefWindow & PrefUI // Maintenance fix. --- .../UIModules/PrefUI/VwrPrefPaneCandidates.swift | 7 ++++--- .../WindowControllers/CtlPrefWindow.swift | 16 +++++----------- Source/WindowNIBs/Base.lproj/frmPrefWindow.xib | 3 ++- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Source/Modules/UIModules/PrefUI/VwrPrefPaneCandidates.swift b/Source/Modules/UIModules/PrefUI/VwrPrefPaneCandidates.swift index ec3777d8..a798df49 100644 --- a/Source/Modules/UIModules/PrefUI/VwrPrefPaneCandidates.swift +++ b/Source/Modules/UIModules/PrefUI/VwrPrefPaneCandidates.swift @@ -221,16 +221,17 @@ private struct VwrPrefPaneCandidates_SelectionKeys: View { items: CandidateKey.suggestions, text: $candidateKeys.onChange { let value = candidateKeys - let keys: String = value.trimmingCharacters(in: .whitespacesAndNewlines).deduplicated + let keys = value.trimmingCharacters(in: .whitespacesAndNewlines).lowercased().deduplicated // Start Error Handling. if let errorResult = CandidateKey.validate(keys: keys) { if let window = CtlPrefUIShared.sharedWindow, !keys.isEmpty { IMEApp.buzz() let alert = NSAlert(error: NSLocalizedString("Invalid Selection Keys.", comment: "")) alert.informativeText = errorResult - alert.beginSheetModal(for: window) + alert.beginSheetModal(for: window) { _ in + candidateKeys = PrefMgr.kDefaultCandidateKeys + } } - candidateKeys = PrefMgr.kDefaultCandidateKeys } } ).frame(width: 180).disabled(useIMKCandidateWindow) diff --git a/Source/Modules/WindowControllers/CtlPrefWindow.swift b/Source/Modules/WindowControllers/CtlPrefWindow.swift index 5aa8125d..4692555c 100644 --- a/Source/Modules/WindowControllers/CtlPrefWindow.swift +++ b/Source/Modules/WindowControllers/CtlPrefWindow.swift @@ -296,19 +296,13 @@ class CtlPrefWindow: NSWindowController, NSWindowDelegate { IMEApp.buzz() } - @IBAction func changeSelectionKeyAction(_ sender: Any) { - guard - let keys = (sender as AnyObject).stringValue?.trimmingCharacters( - in: .whitespacesAndNewlines - ) - .deduplicated - else { - selectionKeyComboBox.stringValue = PrefMgr.shared.candidateKeys - return - } + @IBAction func changeSelectionKeyAction(_: Any) { + let keys = selectionKeyComboBox.stringValue.trimmingCharacters( + in: .whitespacesAndNewlines + ).lowercased().deduplicated + // Start Error Handling. guard let errorResult = CandidateKey.validate(keys: keys) else { PrefMgr.shared.candidateKeys = keys - selectionKeyComboBox.stringValue = PrefMgr.shared.candidateKeys return } if let window = window { diff --git a/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib b/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib index af196f49..4f4f0d53 100644 --- a/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib +++ b/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib @@ -674,6 +674,7 @@ + NSNegateBoolean @@ -1862,7 +1863,7 @@ DQ - +