ctlIME // Bind alphanumerical mode preferences.

This commit is contained in:
ShikiSuen 2022-03-01 18:11:04 +08:00
parent 8a3b98d9f2
commit 8c7c0446a3
1 changed files with 9 additions and 1 deletions

View File

@ -92,6 +92,10 @@ class ctlInputMethod: IMKInputController {
userAssociatedPhrasesItem.keyEquivalentModifierMask = [.command, .control] userAssociatedPhrasesItem.keyEquivalentModifierMask = [.command, .control]
userAssociatedPhrasesItem.state = Preferences.associatedPhrasesEnabled.state userAssociatedPhrasesItem.state = Preferences.associatedPhrasesEnabled.state
let alphaNumericalModeItem = menu.addItem(withTitle: NSLocalizedString("Alphanumerical Input Mode", comment: ""), action: #selector(toggleAlphanumericalModeEnabled(_:)), keyEquivalent: "I")
alphaNumericalModeItem.keyEquivalentModifierMask = [.command, .control]
alphaNumericalModeItem.state = Preferences.isAlphanumericalModeEnabled.state
if optionKeyPressed { if optionKeyPressed {
let phaseReplacementItem = menu.addItem(withTitle: NSLocalizedString("Use Phrase Replacement", comment: ""), action: #selector(togglePhraseReplacement(_:)), keyEquivalent: "") let phaseReplacementItem = menu.addItem(withTitle: NSLocalizedString("Use Phrase Replacement", comment: ""), action: #selector(togglePhraseReplacement(_:)), keyEquivalent: "")
phaseReplacementItem.state = Preferences.phraseReplacementEnabled.state phaseReplacementItem.state = Preferences.phraseReplacementEnabled.state
@ -249,6 +253,10 @@ class ctlInputMethod: IMKInputController {
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Associated Phrases", comment: ""), "\n", Preferences.toggleAssociatedPhrasesEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Associated Phrases", comment: ""), "\n", Preferences.toggleAssociatedPhrasesEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
} }
@objc func toggleAlphanumericalModeEnabled(_ sender: Any?) {
Preferences.toggleAlphanumericalModeEnabled()
}
@objc func togglePhraseReplacement(_ sender: Any?) { @objc func togglePhraseReplacement(_ sender: Any?) {
mgrLangModel.setPhraseReplacementEnabled(Preferences.togglePhraseReplacementEnabled()) mgrLangModel.setPhraseReplacementEnabled(Preferences.togglePhraseReplacementEnabled())
} }