Repo // Refuse ineffective candidate key events.
This commit is contained in:
parent
b510ee5c1e
commit
ec35ebf24b
|
@ -202,6 +202,7 @@ public class CtlCandidateTDK: CtlCandidate {
|
||||||
|
|
||||||
override public func candidateIndexAtKeyLabelIndex(_ id: Int) -> Int {
|
override public func candidateIndexAtKeyLabelIndex(_ id: Int) -> Int {
|
||||||
let arrCurrentLine = thePool.candidateLines[thePool.currentLineNumber]
|
let arrCurrentLine = thePool.candidateLines[thePool.currentLineNumber]
|
||||||
|
if !(0..<arrCurrentLine.count).contains(id) { return -114_514 }
|
||||||
let actualID = max(0, min(id, arrCurrentLine.count - 1))
|
let actualID = max(0, min(id, arrCurrentLine.count - 1))
|
||||||
return arrCurrentLine[actualID].index
|
return arrCurrentLine[actualID].index
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,7 +242,7 @@ extension KeyHandler {
|
||||||
|
|
||||||
if index != NSNotFound {
|
if index != NSNotFound {
|
||||||
let candidateIndex = ctlCandidate.candidateIndexAtKeyLabelIndex(index)
|
let candidateIndex = ctlCandidate.candidateIndexAtKeyLabelIndex(index)
|
||||||
if candidateIndex != Int.max {
|
if candidateIndex != -114_514 {
|
||||||
delegate?.candidateSelectionCalledByKeyHandler(at: candidateIndex)
|
delegate?.candidateSelectionCalledByKeyHandler(at: candidateIndex)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ extension KeyHandler {
|
||||||
|
|
||||||
if shouldAutoSelectCandidate {
|
if shouldAutoSelectCandidate {
|
||||||
let candidateIndex = ctlCandidate.candidateIndexAtKeyLabelIndex(0)
|
let candidateIndex = ctlCandidate.candidateIndexAtKeyLabelIndex(0)
|
||||||
if candidateIndex != Int.max {
|
if candidateIndex != -114_514 {
|
||||||
delegate?.candidateSelectionCalledByKeyHandler(at: candidateIndex)
|
delegate?.candidateSelectionCalledByKeyHandler(at: candidateIndex)
|
||||||
stateCallback(IMEState.ofAbortion())
|
stateCallback(IMEState.ofAbortion())
|
||||||
return handle(
|
return handle(
|
||||||
|
|
Loading…
Reference in New Issue