PrefWindow & PrefUI // Maintenance fix.

This commit is contained in:
ShikiSuen 2023-06-17 21:37:44 +08:00
parent f38db788a5
commit 2a5f02601c
3 changed files with 11 additions and 15 deletions

View File

@ -221,18 +221,19 @@ 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
}
}
}
}
).frame(width: 180).disabled(useIMKCandidateWindow)
if useIMKCandidateWindow {
Text(

View File

@ -296,19 +296,13 @@ class CtlPrefWindow: NSWindowController, NSWindowDelegate {
IMEApp.buzz()
}
@IBAction func changeSelectionKeyAction(_ sender: Any) {
guard
let keys = (sender as AnyObject).stringValue?.trimmingCharacters(
@IBAction func changeSelectionKeyAction(_: Any) {
let keys = selectionKeyComboBox.stringValue.trimmingCharacters(
in: .whitespacesAndNewlines
)
.deduplicated
else {
selectionKeyComboBox.stringValue = PrefMgr.shared.candidateKeys
return
}
).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 {

View File

@ -674,6 +674,7 @@
</comboBoxCell>
<connections>
<action selector="changeSelectionKeyAction:" target="-2" id="REj-7y-bbQ"/>
<binding destination="32" name="value" keyPath="values.CandidateKeys" id="5Fv-A4-QY5"/>
<binding destination="32" name="enabled" keyPath="values.UseIMKCandidateWindow" id="BDQ-gl-txA">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
@ -1862,7 +1863,7 @@ DQ
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="70" id="g7o-3C-NrU"/>
</constraints>
<connections>
<binding destination="32" name="value" keyPath="values.AutoCombineLongestPossibleCassetteKey" id="VUF-y7-K67"/>
<binding destination="32" name="value" keyPath="values.AutoCompositeWithLongestPossibleCassetteKey" id="OSk-i5-Mdr"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3eW-vq-tFr">