diff --git a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift index 231442c5..880c3dc2 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift @@ -81,11 +81,12 @@ class ctlInputMethod: IMKInputController { keyHandler.composer.clear() handle(state: keyHandler.buildInputtingState) } - if state.hasComposition { + let isSecureMode = mgrPrefs.clientsIMKTextInputIncapable.contains(clientBundleIdentifier) + if state.hasComposition, !isSecureMode { /// 將傳回的新狀態交給調度函式。 handle(state: IMEState.ofCommitting(textToCommit: state.displayedText)) } - handle(state: IMEState.ofEmpty()) + handle(state: isSecureMode ? IMEState.ofAbortion() : IMEState.ofEmpty()) } // MARK: - IMKInputController 方法 diff --git a/Source/Modules/ControllerModules/ctlInputMethod_HandleDisplay.swift b/Source/Modules/ControllerModules/ctlInputMethod_HandleDisplay.swift index 7e7d25b2..a3d64931 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_HandleDisplay.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_HandleDisplay.swift @@ -13,6 +13,15 @@ import Cocoa // MARK: - Tooltip Display and Candidate Display Methods extension ctlInputMethod { + // 有些 App 會濫用內文組字區的內容來預測使用者的輸入行為。 + // 對此類 App 有疑慮者,可以將這類 App 登記到客體管理員當中。 + // 這樣,不但強制使用(限制讀音 20 個的)浮動組字窗,而且內文組字區只會顯示一個空格。 + var attributedStringSecured: (NSAttributedString, NSRange) { + mgrPrefs.clientsIMKTextInputIncapable.contains(clientBundleIdentifier) + ? (state.data.attributedStringPlaceholder, NSRange(location: 0, length: 0)) + : (state.attributedString, NSRange(state.data.u16MarkedRange)) + } + func lineHeightRect(zeroCursor: Bool = false) -> NSRect { var lineHeightRect = NSRect.seniorTheBeast guard let client = client() else { diff --git a/Source/Modules/ControllerModules/ctlInputMethod_HandleStates.swift b/Source/Modules/ControllerModules/ctlInputMethod_HandleStates.swift index 12423441..410ce31f 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_HandleStates.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_HandleStates.swift @@ -96,7 +96,7 @@ extension ctlInputMethod { guard let client = client() else { return } if state.type == .ofAssociates { client.setMarkedText( - state.attributedString, selectionRange: NSRange(location: 0, length: 0), + state.data.attributedStringPlaceholder, selectionRange: NSRange(location: 0, length: 0), replacementRange: NSRange(location: NSNotFound, length: NSNotFound) ) return @@ -107,7 +107,7 @@ extension ctlInputMethod { /// 是 0 且取代範圍(replacementRange)為「NSNotFound」罷了。 /// 也就是說,內文組字區該在哪裡出現,得由客體軟體來作主。 client.setMarkedText( - state.attributedString, selectionRange: NSRange(state.data.u16MarkedRange), + attributedStringSecured.0, selectionRange: attributedStringSecured.1, replacementRange: NSRange(location: NSNotFound, length: NSNotFound) ) return