From 5aa1729bd19382ba81bebfe1ba498b3a49de10f3 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 8 Aug 2022 10:44:50 +0800 Subject: [PATCH] ctlIME // Chromium compatibility with Alphanumerical mode toggle. - Finally patched this ****. --- .../ctlInputMethod_Core.swift | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift index 1aa3cc3f..4e92733b 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift @@ -46,6 +46,9 @@ class ctlInputMethod: IMKInputController { return isASCIIMode } + /// `handle(event:)` 會利用這個參數判定某次 Shift 按鍵是否用來切換中英文輸入。 + private var rencentKeyHandledByKeyHandler = false + // MARK: - 工具函式 /// 指定鍵盤佈局。 @@ -188,13 +191,17 @@ class ctlInputMethod: IMKInputController { // 用 Shift 開關半形英數模式。 if ShiftKeyUpChecker.check(event) { - NotifierController.notify( - message: String( - format: "%@%@%@", NSLocalizedString("Alphanumerical Mode", comment: ""), "\n", - toggleASCIIMode() - ? NSLocalizedString("NotificationSwitchON", comment: "") - : NSLocalizedString("NotificationSwitchOFF", comment: "") - )) + if !rencentKeyHandledByKeyHandler { + NotifierController.notify( + message: String( + format: "%@%@%@", NSLocalizedString("Alphanumerical Mode", comment: ""), "\n", + toggleASCIIMode() + ? NSLocalizedString("NotificationSwitchON", comment: "") + : NSLocalizedString("NotificationSwitchOFF", comment: "") + ) + ) + } + rencentKeyHandledByKeyHandler = false return false } @@ -240,6 +247,7 @@ class ctlInputMethod: IMKInputController { } errorCallback: { clsSFX.beep() } + rencentKeyHandledByKeyHandler = result return result }