Repo // Make candidateIndexAtKeyLabelIndex() nullable.
This commit is contained in:
parent
2289be50b6
commit
888e6a9ddf
|
@ -109,7 +109,7 @@ open class CtlCandidate: NSWindowController, CtlCandidateProtocol {
|
|||
false
|
||||
}
|
||||
|
||||
open func candidateIndexAtKeyLabelIndex(_: Int) -> Int {
|
||||
open func candidateIndexAtKeyLabelIndex(_: Int) -> Int? {
|
||||
Int.max
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public protocol CtlCandidateProtocol {
|
|||
func showPreviousLine() -> Bool
|
||||
func highlightNextCandidate() -> Bool
|
||||
func highlightPreviousCandidate() -> Bool
|
||||
func candidateIndexAtKeyLabelIndex(_: Int) -> Int
|
||||
func candidateIndexAtKeyLabelIndex(_: Int) -> Int?
|
||||
func set(windowTopLeftPoint: NSPoint, bottomOutOfScreenAdjustmentHeight height: Double, useGCD: Bool)
|
||||
}
|
||||
|
||||
|
|
|
@ -141,8 +141,7 @@ extension InputHandler {
|
|||
}
|
||||
|
||||
if index != NSNotFound {
|
||||
let candidateIndex = ctlCandidate.candidateIndexAtKeyLabelIndex(index)
|
||||
if candidateIndex != -114_514 {
|
||||
if let candidateIndex = ctlCandidate.candidateIndexAtKeyLabelIndex(index) {
|
||||
delegate.candidateSelectionCalledByInputHandler(at: candidateIndex)
|
||||
return true
|
||||
}
|
||||
|
@ -185,13 +184,10 @@ extension InputHandler {
|
|||
}
|
||||
|
||||
if shouldAutoSelectCandidate {
|
||||
let candidateIndex = ctlCandidate.candidateIndexAtKeyLabelIndex(0)
|
||||
if candidateIndex != -114_514 {
|
||||
delegate.candidateSelectionCalledByInputHandler(at: candidateIndex)
|
||||
delegate.switchState(IMEState.ofAbortion())
|
||||
return handleInput(event: input)
|
||||
}
|
||||
return true
|
||||
guard let candidateIndex = ctlCandidate.candidateIndexAtKeyLabelIndex(0) else { return true }
|
||||
delegate.candidateSelectionCalledByInputHandler(at: candidateIndex)
|
||||
delegate.switchState(IMEState.ofAbortion())
|
||||
return handleInput(event: input)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ public class CtlCandidateIMK: IMKCandidates, CtlCandidateProtocol {
|
|||
}
|
||||
|
||||
// IMK 選字窗目前無法實作該函式。威注音 IMK 選字窗目前也不需要使用該函式。
|
||||
public func candidateIndexAtKeyLabelIndex(_: Int) -> Int { 0 }
|
||||
public func candidateIndexAtKeyLabelIndex(_: Int) -> Int? { 0 }
|
||||
|
||||
public var highlightedIndex: Int {
|
||||
get { selectedCandidate() }
|
||||
|
|
Loading…
Reference in New Issue