ctlIME // Simplify isASCIIMode toggling.

This commit is contained in:
ShikiSuen 2022-09-21 21:21:46 +08:00
parent e577135079
commit 827e7e4735
1 changed files with 8 additions and 9 deletions

View File

@ -39,7 +39,13 @@ class ctlInputMethod: IMKInputController {
// MARK: - // MARK: -
/// ctlInputMethod /// ctlInputMethod
var isASCIIMode = false { didSet { setKeyLayout() } } var isASCIIMode = false {
didSet {
resetKeyHandler()
setKeyLayout()
}
}
/// 調 /// 調
var keyHandler = KeyHandler(lm: LMMgr.currentLM(), uom: LMMgr.currentUOM(), pref: PrefMgr.shared) var keyHandler = KeyHandler(lm: LMMgr.currentLM(), uom: LMMgr.currentUOM(), pref: PrefMgr.shared)
/// ///
@ -53,13 +59,6 @@ class ctlInputMethod: IMKInputController {
/// - Remark: Struct CapsLock Shift /// - Remark: Struct CapsLock Shift
static var theShiftKeyDetector = ShiftKeyUpChecker(useLShift: PrefMgr.shared.togglingAlphanumericalModeWithLShift) static var theShiftKeyDetector = ShiftKeyUpChecker(useLShift: PrefMgr.shared.togglingAlphanumericalModeWithLShift)
/// ctlInputMethod
func toggleASCIIMode() -> Bool {
resetKeyHandler()
isASCIIMode.toggle()
return isASCIIMode
}
/// `handle(event:)` Shift /// `handle(event:)` Shift
var rencentKeyHandledByKeyHandlerEtc = false var rencentKeyHandledByKeyHandlerEtc = false
@ -274,7 +273,7 @@ class ctlInputMethod: IMKInputController {
if Self.theShiftKeyDetector.check(event), !PrefMgr.shared.disableShiftTogglingAlphanumericalMode { if Self.theShiftKeyDetector.check(event), !PrefMgr.shared.disableShiftTogglingAlphanumericalMode {
if !shouldUseShiftToggleHandle || (!rencentKeyHandledByKeyHandlerEtc && shouldUseShiftToggleHandle) { if !shouldUseShiftToggleHandle || (!rencentKeyHandledByKeyHandlerEtc && shouldUseShiftToggleHandle) {
NotifierController.notify( NotifierController.notify(
message: toggleASCIIMode() message: isASCIIMode.toggled()
? NSLocalizedString("Alphanumerical Input Mode", comment: "") ? NSLocalizedString("Alphanumerical Input Mode", comment: "")
: NSLocalizedString("Chinese Input Mode", comment: "") : NSLocalizedString("Chinese Input Mode", comment: "")
) )