InputHandler // Improve handling of invalid inputs.
This commit is contained in:
parent
e334fc60ec
commit
35d3c344ec
|
@ -111,7 +111,8 @@ extension InputHandler {
|
|||
}
|
||||
|
||||
// 將該讀音插入至組字器內的軌格當中。
|
||||
if !compositor.insertKey(readingKey) {
|
||||
// 提前過濾掉一些不合規的按鍵訊號輸入,免得相關按鍵訊號被送給 Megrez 引發輸入法崩潰。
|
||||
if !input.isInvalid, !compositor.insertKey(readingKey) {
|
||||
delegate.callError("3CF278C9: 得檢查對應的語言模組的 hasUnigramsFor() 是否有誤判之情形。")
|
||||
return true
|
||||
}
|
||||
|
@ -253,7 +254,8 @@ extension InputHandler {
|
|||
}
|
||||
|
||||
// 將該讀音插入至組字器內的軌格當中。
|
||||
if !compositor.insertKey(calligrapher) {
|
||||
// 提前過濾掉一些不合規的按鍵訊號輸入,免得相關按鍵訊號被送給 Megrez 引發輸入法崩潰。
|
||||
if !input.isInvalid, !compositor.insertKey(calligrapher) {
|
||||
delegate.callError("61F6B11F: 得檢查對應的語言模組的 hasUnigramsFor() 是否有誤判之情形。")
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -31,14 +31,8 @@ extension InputHandler {
|
|||
let inputText: String = input.text
|
||||
var state: IMEStateProtocol { delegate.state } // 常數轉變數。
|
||||
|
||||
// 提前過濾掉一些不合規的按鍵訊號輸入,免得相關按鍵訊號被送給 Megrez 引發輸入法崩潰。
|
||||
if input.isInvalid {
|
||||
// 在「.Empty(IgnoringPreviousState) 與 .Deactivated」狀態下的首次不合規按鍵輸入可以直接放行。
|
||||
// 因為「.Abortion」會在處理之後被自動轉為「.Empty」,所以不需要單獨判斷。
|
||||
if state.type == .ofEmpty || state.type == .ofDeactivated { return false }
|
||||
delegate.callError("550BCF7B: InputHandler just refused an invalid input.")
|
||||
return true
|
||||
}
|
||||
// 提前放行一些用不到的特殊按鍵輸入情形。
|
||||
if input.isInvalid, state.type == .ofEmpty || state.type == .ofDeactivated { return false }
|
||||
|
||||
// 如果當前組字器為空的話,就不再攔截某些修飾鍵,畢竟這些鍵可能會會用來觸發某些功能。
|
||||
let isFunctionKey: Bool =
|
||||
|
|
Loading…
Reference in New Issue