From 45c8620c016fa4a8eb716dc450b2d31f1ad52e50 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 21 Jun 2023 21:40:04 +0800 Subject: [PATCH] InputHandler // +useSpaceToCommitHighlightedSCPCCandidate(). --- Source/Modules/InputHandler_HandleCandidate.swift | 4 ++++ Source/Modules/InputHandler_HandleEvent.swift | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Source/Modules/InputHandler_HandleCandidate.swift b/Source/Modules/InputHandler_HandleCandidate.swift index a653b361..67c6acfb 100644 --- a/Source/Modules/InputHandler_HandleCandidate.swift +++ b/Source/Modules/InputHandler_HandleCandidate.swift @@ -106,6 +106,10 @@ extension InputHandler { _ = updated ? {}() : delegate.callError("9B691919") return true case .kSpace where state.type != .ofInputting: + guard !(prefs.useSpaceToCommitHighlightedSCPCCandidate && prefs.useSCPCTypingMode) else { + delegate.candidateSelectionConfirmedByInputHandler(at: ctlCandidate.highlightedIndex) + return true + } let updated: Bool = prefs.specifyShiftSpaceKeyBehavior ? (input.isShiftHold diff --git a/Source/Modules/InputHandler_HandleEvent.swift b/Source/Modules/InputHandler_HandleEvent.swift index 629e06c8..8649556f 100644 --- a/Source/Modules/InputHandler_HandleEvent.swift +++ b/Source/Modules/InputHandler_HandleEvent.swift @@ -8,6 +8,7 @@ /// 該檔案乃輸入調度模組當中用來預處理 NSEvent 的模組。 +import CocoaExtension import InputMethodKit import Shared @@ -99,6 +100,18 @@ extension InputHandler { } return true } else if event.isSpace { + if prefs.useSpaceToCommitHighlightedSCPCCandidate, prefs.useSCPCTypingMode, + let eventTranslated = event.reinitiate(keyCode: KeyCode.kCarriageReturn.rawValue) + { + if #available(macOS 10.14, *) { + PrefMgr.shared.failureFlagForIMKCandidates = true + imkC.handleKeyboardEvent(eventTranslated) + PrefMgr.shared.failureFlagForIMKCandidates = false + } else { + imkC.interpretKeyEvents([eventTranslated]) + } + return true + } switch prefs.specifyShiftSpaceKeyBehavior { case true: _ = event.isShiftHold ? imkC.highlightNextCandidate() : imkC.showNextPage() case false: _ = event.isShiftHold ? imkC.showNextPage() : imkC.highlightNextCandidate()