InputHandler // Tweak pipeline for NSEvents with empty texts.
This commit is contained in:
parent
53182e2690
commit
bf8d9f30f0
|
@ -17,6 +17,8 @@ extension InputHandler {
|
|||
/// - input: 輸入訊號。
|
||||
/// - Returns: 告知 IMK「該按鍵是否已經被輸入法攔截處理」。
|
||||
func handleComposition(input: InputSignalProtocol) -> Bool? {
|
||||
// 不處理任何包含不可列印字元的訊號。
|
||||
guard !input.text.isEmpty, input.charCode.isPrintable else { return nil }
|
||||
if isCodePointInputMode { return handleCodePointComposition(input: input) }
|
||||
if prefs.cassetteEnabled { return handleCassetteComposition(input: input) }
|
||||
return handlePhonabetComposition(input: input)
|
||||
|
|
|
@ -23,10 +23,8 @@ extension InputHandler {
|
|||
/// - input: 輸入訊號。
|
||||
/// - Returns: 告知 IMK「該按鍵是否已經被輸入法攔截處理」。
|
||||
func handleInput(event input: InputSignalProtocol) -> Bool {
|
||||
// 如果按鍵訊號內的 inputTest 是空的話,則忽略該按鍵輸入,因為很可能是功能修飾鍵。
|
||||
// 不處理任何包含不可列印字元的訊號。
|
||||
// delegate 必須存在,否則不處理。
|
||||
guard !input.text.isEmpty, input.charCode.isPrintable, let delegate = delegate else { return false }
|
||||
guard let delegate = delegate else { return false }
|
||||
|
||||
let inputText: String = input.text
|
||||
var state: IMEStateProtocol { delegate.state } // 常數轉變數。
|
||||
|
@ -83,6 +81,12 @@ extension InputHandler {
|
|||
|
||||
if [.ofCandidates, .ofSymbolTable].contains(state.type) { return handleCandidate(input: input) }
|
||||
|
||||
// MARK: 攔截部分無效按鍵。
|
||||
|
||||
// 如果按鍵訊號內的 inputTest 是空的話,則忽略該按鍵輸入,因為很可能是功能修飾鍵。
|
||||
// 不處理任何包含不可列印字元的訊號。
|
||||
guard !input.text.isEmpty, input.charCode.isPrintable else { return false }
|
||||
|
||||
// MARK: 處理聯想詞 (Handle Associated Phrases)
|
||||
|
||||
if state.type == .ofAssociates {
|
||||
|
|
Loading…
Reference in New Issue