InputHandler // +useSpaceToCommitHighlightedSCPCCandidate().

This commit is contained in:
ShikiSuen 2023-06-21 21:40:04 +08:00
parent e8cd2ebb8f
commit 45c8620c01
2 changed files with 17 additions and 0 deletions

View File

@ -106,6 +106,10 @@ extension InputHandler {
_ = updated ? {}() : delegate.callError("9B691919") _ = updated ? {}() : delegate.callError("9B691919")
return true return true
case .kSpace where state.type != .ofInputting: case .kSpace where state.type != .ofInputting:
guard !(prefs.useSpaceToCommitHighlightedSCPCCandidate && prefs.useSCPCTypingMode) else {
delegate.candidateSelectionConfirmedByInputHandler(at: ctlCandidate.highlightedIndex)
return true
}
let updated: Bool = let updated: Bool =
prefs.specifyShiftSpaceKeyBehavior prefs.specifyShiftSpaceKeyBehavior
? (input.isShiftHold ? (input.isShiftHold

View File

@ -8,6 +8,7 @@
/// 調 NSEvent /// 調 NSEvent
import CocoaExtension
import InputMethodKit import InputMethodKit
import Shared import Shared
@ -99,6 +100,18 @@ extension InputHandler {
} }
return true return true
} else if event.isSpace { } 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 { switch prefs.specifyShiftSpaceKeyBehavior {
case true: _ = event.isShiftHold ? imkC.highlightNextCandidate() : imkC.showNextPage() case true: _ = event.isShiftHold ? imkC.highlightNextCandidate() : imkC.showNextPage()
case false: _ = event.isShiftHold ? imkC.showNextPage() : imkC.highlightNextCandidate() case false: _ = event.isShiftHold ? imkC.showNextPage() : imkC.highlightNextCandidate()