From 8f7d5a8a2a7110f93a6f8691d65918dd7e16d507 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 8 Sep 2022 15:32:16 +0800 Subject: [PATCH] ctlIME // Reset KeyHandler if nil is passed to handle(event:). --- .../Modules/ControllerModules/ctlInputMethod_Core.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift index 56f1617b..87dd7639 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift @@ -207,15 +207,16 @@ class ctlInputMethod: IMKInputController { @objc(handleEvent:client:) override func handle(_ event: NSEvent!, client sender: Any!) -> Bool { _ = sender // 防止格式整理工具毀掉與此對應的參數。 - // 只針對特定類型的 client() 進行處理。 - if !(sender is IMKTextInput) { return false } - // 更新此時的靜態狀態標記。 ctlInputMethod.isASCIIModeSituation = isASCIIMode ctlInputMethod.isVerticalTypingSituation = isVerticalTyping // 就這傳入的 NSEvent 都還有可能是 nil,Apple InputMethodKit 團隊到底在搞三小。 - guard let event = event else { return false } + // 只針對特定類型的 client() 進行處理。 + guard let event = event, sender is IMKTextInput else { + resetKeyHandler() + return false + } // IMK 選字窗處理,當且僅當啟用了 IMK 選字窗的時候才會生效。 // 這樣可以讓 interpretKeyEvents() 函式自行判斷: