From d14b61781e9b37aa4f92d9b2b390e0c755cf16cb Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 15 Feb 2022 13:08:23 +0800 Subject: [PATCH] IME // Disable BPMF-Commit except typing into our user phrase editor. - Otherwise, it may disturb user experiences in usual cases. --- Source/Modules/ControllerModules/KeyHandler.mm | 4 +++- Source/Modules/IMEModules/ctlInputMethod.swift | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 9956694b..85e55695 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -491,7 +491,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; // MARK: Enter if (charCode == 13) { if ([input isControlHold]) { - return [self _handleCtrlEnterWithState:state stateCallback:stateCallback errorCallback:errorCallback]; + if (ctlInputMethod.areWeUsingOurOwnPhraseEditor) { + return [self _handleCtrlEnterWithState:state stateCallback:stateCallback errorCallback:errorCallback]; + } } return [self _handleEnterWithState:state stateCallback:stateCallback errorCallback:errorCallback]; } diff --git a/Source/Modules/IMEModules/ctlInputMethod.swift b/Source/Modules/IMEModules/ctlInputMethod.swift index 1549a24c..f8c97af8 100644 --- a/Source/Modules/IMEModules/ctlInputMethod.swift +++ b/Source/Modules/IMEModules/ctlInputMethod.swift @@ -185,6 +185,12 @@ class ctlInputMethod: IMKInputController { var textFrame = NSRect.zero let attributes: [AnyHashable: Any]? = (client as? IMKTextInput)?.attributes(forCharacterIndex: 0, lineHeightRectangle: &textFrame) let useVerticalMode = (attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false + + if (client as? IMKTextInput)?.bundleIdentifier() == "org.atelierInmu.vChewing.vChewingPhraseEditor" { + ctlInputMethod.areWeUsingOurOwnPhraseEditor = true + } else { + ctlInputMethod.areWeUsingOurOwnPhraseEditor = false + } let input = KeyHandlerInput(event: event, isVerticalMode: useVerticalMode) @@ -554,6 +560,12 @@ extension ctlInputMethod { } } +// MARK: - 開關判定當前應用究竟是? + +@objc extension ctlInputMethod { + @objc static var areWeUsingOurOwnPhraseEditor: Bool = false +} + // MARK: - extension ctlInputMethod: KeyHandlerDelegate {