IMKCandidates // Use InputSignalProtocol.

This commit is contained in:
ShikiSuen 2022-09-01 14:09:33 +08:00
parent 95abbea039
commit ee6b77001a
1 changed files with 15 additions and 16 deletions

View File

@ -206,25 +206,24 @@ public class ctlCandidateIMK: IMKCandidates, ctlCandidateProtocol {
// Objective-C nil
guard !eventArray.isEmpty else { return }
let event = eventArray[0]
let input = InputSignal(event: event)
guard let delegate = delegate else { return }
if input.isEsc || input.isBackSpace || input.isDelete || (input.isShiftHold && !input.isSpace) {
if event.isEsc || event.isBackSpace || event.isDelete || (event.isShiftHold && !event.isSpace) {
_ = delegate.sharedEventHandler(event)
} else if input.isSymbolMenuPhysicalKey {
} else if event.isSymbolMenuPhysicalKey {
//
switch currentLayout {
case .horizontal: input.isShiftHold ? moveUp(self) : moveDown(self)
case .vertical: input.isShiftHold ? moveLeft(self) : moveRight(self)
case .horizontal: event.isShiftHold ? moveUp(self) : moveDown(self)
case .vertical: event.isShiftHold ? moveLeft(self) : moveRight(self)
}
} else if input.isSpace {
} else if event.isSpace {
switch mgrPrefs.specifyShiftSpaceKeyBehavior {
case true: _ = input.isShiftHold ? highlightNextCandidate() : showNextPage()
case false: _ = input.isShiftHold ? showNextPage() : highlightNextCandidate()
case true: _ = event.isShiftHold ? highlightNextCandidate() : showNextPage()
case false: _ = event.isShiftHold ? showNextPage() : highlightNextCandidate()
}
} else if input.isTab {
} else if event.isTab {
switch mgrPrefs.specifyShiftTabKeyBehavior {
case true: _ = input.isShiftHold ? showPreviousPage() : showNextPage()
case false: _ = input.isShiftHold ? highlightPreviousCandidate() : highlightNextCandidate()
case true: _ = event.isShiftHold ? showPreviousPage() : showNextPage()
case false: _ = event.isShiftHold ? highlightPreviousCandidate() : highlightNextCandidate()
}
} else {
if let newChar = ctlCandidateIMK.defaultIMKSelectionKey[event.keyCode] {
@ -245,7 +244,7 @@ public class ctlCandidateIMK: IMKCandidates, ctlCandidateProtocol {
if let newEvent = newEvent {
if mgrPrefs.useSCPCTypingMode, delegate.isAssociatedPhrasesState {
// input.isShiftHold ctlInputMethod.handle()
if !input.isShiftHold {
if !event.isShiftHold {
_ = delegate.sharedEventHandler(event)
return
}
@ -256,15 +255,15 @@ public class ctlCandidateIMK: IMKCandidates, ctlCandidateProtocol {
}
}
if mgrPrefs.useSCPCTypingMode, !input.isReservedKey {
if mgrPrefs.useSCPCTypingMode, !event.isReservedKey {
_ = delegate.sharedEventHandler(event)
return
}
if delegate.isAssociatedPhrasesState,
!input.isPageUp, !input.isPageDown, !input.isCursorForward, !input.isCursorBackward,
!input.isCursorClockLeft, !input.isCursorClockRight, !input.isSpace,
!input.isEnter || !mgrPrefs.alsoConfirmAssociatedCandidatesByEnter
!event.isPageUp, !event.isPageDown, !event.isCursorForward, !event.isCursorBackward,
!event.isCursorClockLeft, !event.isCursorClockRight, !event.isSpace,
!event.isEnter || !mgrPrefs.alsoConfirmAssociatedCandidatesByEnter
{
_ = delegate.sharedEventHandler(event)
return