IMKCandidates // Patch highlightedIndex().

This commit is contained in:
ShikiSuen 2023-06-24 21:18:53 +08:00
parent 234c2656b7
commit 8dc7c027fc
2 changed files with 6 additions and 1 deletions

View File

@ -14,6 +14,7 @@ public protocol CtlCandidateDelegate {
func candidatePairHighlightChanged(at index: Int)
func candidatePairRightClicked(at index: Int, action: CandidateContextMenuAction)
func candidates(_ sender: Any!) -> [Any]!
func deductCandidateIndex(from candidateString: String) -> Int
func resetCandidateWindowOrigin()
@discardableResult func reverseLookup(for value: String) -> [String]
var selectionKeys: String { get }

View File

@ -148,7 +148,11 @@ public class CtlCandidateIMK: IMKCandidates, CtlCandidateProtocol {
public func candidateIndexAtKeyLabelIndex(_: Int) -> Int? { 0 }
public var highlightedIndex: Int {
get { selectedCandidate() }
get {
let returned = selectedCandidate()
guard let strCurrentCandidate = selectedCandidateString() else { return returned }
return delegate?.deductCandidateIndex(from: strCurrentCandidate.string) ?? returned
}
set { selectCandidate(withIdentifier: newValue) }
}
}