From 1e178e948f1d9cd1696541ddec31f1eb6c650af8 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 27 Oct 2022 13:46:01 +0800 Subject: [PATCH] Repo // Stop committing raw dynamic keylayout chars. (#202) --- Source/Modules/InputHandler_HandleInput.swift | 8 -------- Source/Modules/SessionCtl_HandleEvent.swift | 9 +++++++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Source/Modules/InputHandler_HandleInput.swift b/Source/Modules/InputHandler_HandleInput.swift index 1aea2887..18494529 100644 --- a/Source/Modules/InputHandler_HandleInput.swift +++ b/Source/Modules/InputHandler_HandleInput.swift @@ -277,14 +277,6 @@ extension InputHandler { return true } - // 將 Apple 動態鍵盤佈局的 RAW 輸出轉為 ABC 輸出。僅對磁帶模式啟用此步驟。 - if IMKHelper.isDynamicBasicKeyboardLayoutEnabled, let event = input as? NSEvent, - prefs.cassetteEnabled, let txtABC = event.inAppleABCStaticForm.characters, !txtABC.isEmpty - { - delegate.switchState(IMEState.ofCommitting(textToCommit: txtABC)) - return true - } - return false } } diff --git a/Source/Modules/SessionCtl_HandleEvent.swift b/Source/Modules/SessionCtl_HandleEvent.swift index 379151a9..c0c95793 100644 --- a/Source/Modules/SessionCtl_HandleEvent.swift +++ b/Source/Modules/SessionCtl_HandleEvent.swift @@ -136,10 +136,15 @@ extension SessionCtl { if shouldUseShiftToggleHandle { rencentKeyHandledByInputHandlerEtc = result } if !result { // 除非是 .ofMarking 狀態,否則讓某些不用去抓的按鍵起到「取消工具提示」的作用。 - if [.ofEmpty].contains(state.type) { - tooltipInstance.hide() + if [.ofEmpty].contains(state.type) { tooltipInstance.hide() } + + // 將 Apple 動態鍵盤佈局的 RAW 輸出轉為 ABC 輸出,除非轉換結果與轉換前的內容一致。 + if IMKHelper.isDynamicBasicKeyboardLayoutEnabled, event.text != eventToDeal.text { + switchState(IMEState.ofCommitting(textToCommit: eventToDeal.text)) + return true } } + return result } }