ctlIME // Use InputSignalProtocol.
This commit is contained in:
parent
ee6b77001a
commit
e039e8cadc
|
@ -51,19 +51,16 @@ extension ctlInputMethod {
|
|||
// 準備修飾鍵,用來判定要新增的詞彙是否需要賦以非常低的權重。
|
||||
ctlInputMethod.areWeNerfing = event.modifierFlags.contains([.shift, .command])
|
||||
|
||||
var input = InputSignal(event: event, isVerticalTyping: isVerticalTyping)
|
||||
input.isASCIIModeInput = isASCIIMode
|
||||
|
||||
// 無法列印的訊號輸入,一概不作處理。
|
||||
// 這個過程不能放在 KeyHandler 內,否則不會起作用。
|
||||
if !input.charCode.isPrintable {
|
||||
if !event.charCode.isPrintable {
|
||||
return false
|
||||
}
|
||||
|
||||
/// 將按鍵行為與當前輸入法狀態結合起來、交給按鍵調度模組來處理。
|
||||
/// 再根據返回的 result bool 數值來告知 IMK「這個按鍵事件是被處理了還是被放行了」。
|
||||
/// 這裡不用 keyHandler.handleCandidate() 是因為需要針對聯想詞輸入狀態做額外處理。
|
||||
let result = keyHandler.handle(input: input, state: state) { newState in
|
||||
let result = keyHandler.handle(input: event, state: state) { newState in
|
||||
self.handle(state: newState)
|
||||
} errorCallback: {
|
||||
clsSFX.beep()
|
||||
|
|
|
@ -219,11 +219,10 @@ class ctlInputMethod: IMKInputController {
|
|||
proc: if let ctlCandidateCurrent = ctlInputMethod.ctlCandidateCurrent as? ctlCandidateIMK {
|
||||
guard ctlCandidateCurrent.visible else { break proc }
|
||||
let event: NSEvent = ctlCandidateIMK.replaceNumPadKeyCodes(target: event) ?? event
|
||||
let input = InputSignal(event: event)
|
||||
|
||||
// Shift+Enter 是個特殊情形,不提前攔截處理的話、會有垃圾參數傳給 delegate 的 keyHandler 從而崩潰。
|
||||
// 所以這裡直接將 Shift Flags 清空。
|
||||
if input.isShiftHold, input.isEnter {
|
||||
if event.isShiftHold, event.isEnter {
|
||||
guard
|
||||
let newEvent = NSEvent.keyEvent(
|
||||
with: event.type,
|
||||
|
@ -246,7 +245,7 @@ class ctlInputMethod: IMKInputController {
|
|||
}
|
||||
|
||||
// 聯想詞選字。
|
||||
if let newChar = ctlCandidateIMK.defaultIMKSelectionKey[event.keyCode], input.isShiftHold,
|
||||
if let newChar = ctlCandidateIMK.defaultIMKSelectionKey[event.keyCode], event.isShiftHold,
|
||||
isAssociatedPhrasesState
|
||||
{
|
||||
let newEvent = NSEvent.keyEvent(
|
||||
|
|
Loading…
Reference in New Issue