CtlCandidateTDK // Auto-update tooltips when expanded.
This commit is contained in:
parent
2c132a4f92
commit
4224509dae
|
@ -111,6 +111,7 @@ public class CtlCandidateTDK: CtlCandidate, NSWindowDelegate {
|
|||
if let currentCandidateText = Self.thePool.currentSelectedCandidateText {
|
||||
reverseLookupResult = delegate?.reverseLookup(for: currentCandidateText) ?? []
|
||||
Self.thePool.reverseLookupResult = reverseLookupResult
|
||||
Self.thePool.tooltip = delegate?.candidateToolTip(shortened: !Self.thePool.isMatrix) ?? ""
|
||||
}
|
||||
delegate?.candidatePairHighlightChanged(at: highlightedIndex)
|
||||
DispatchQueue.main.async { [self] in
|
||||
|
|
|
@ -92,6 +92,19 @@ extension SessionCtl: CtlCandidateDelegate {
|
|||
|
||||
public var showReverseLookupResult: Bool { PrefMgr.shared.showReverseLookupInCandidateUI }
|
||||
|
||||
public func candidateToolTip(shortened: Bool) -> String {
|
||||
if state.type == .ofAssociates {
|
||||
return shortened ? "⇧" : NSLocalizedString("Hold ⇧ to choose associates.", comment: "")
|
||||
} else if state.type == .ofInputting, state.isCandidateContainer {
|
||||
let useShift = LMMgr.currentLM.areCassetteCandidateKeysShiftHeld
|
||||
let theEmoji = useShift ? "⬆️" : "⚡️"
|
||||
return shortened ? theEmoji : "\(theEmoji) " + NSLocalizedString("Quick Candidates", comment: "")
|
||||
} else if PrefMgr.shared.cassetteEnabled {
|
||||
return shortened ? "📼" : "📼 " + NSLocalizedString("CIN Cassette Mode", comment: "")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@discardableResult public func reverseLookup(for value: String) -> [String] {
|
||||
let blankResult: [String] = []
|
||||
// 這一段專門處理「反查」。
|
||||
|
|
|
@ -96,19 +96,6 @@ public extension SessionCtl {
|
|||
name: PrefMgr.shared.candidateTextFontName, size: PrefMgr.shared.candidateListTextSize
|
||||
)
|
||||
|
||||
if state.type == .ofAssociates {
|
||||
candidateUI?.tooltip =
|
||||
singleLine ? "⇧" : NSLocalizedString("Hold ⇧ to choose associates.", comment: "")
|
||||
} else if state.type == .ofInputting, state.isCandidateContainer {
|
||||
let useShift = LMMgr.currentLM.areCassetteCandidateKeysShiftHeld
|
||||
let theEmoji = useShift ? "⬆️" : "⚡️"
|
||||
candidateUI?.tooltip =
|
||||
singleLine ? theEmoji : "\(theEmoji) " + NSLocalizedString("Quick Candidates", comment: "")
|
||||
} else if PrefMgr.shared.cassetteEnabled {
|
||||
candidateUI?.tooltip =
|
||||
singleLine ? "📼" : "📼 " + NSLocalizedString("CIN Cassette Mode", comment: "")
|
||||
}
|
||||
|
||||
candidateUI?.locale = {
|
||||
switch inputMode {
|
||||
case .imeModeCHS: return "zh-Hans"
|
||||
|
|
|
@ -13,7 +13,7 @@ public protocol CtlCandidateDelegate {
|
|||
func candidatePairSelectionConfirmed(at index: Int)
|
||||
func candidatePairHighlightChanged(at index: Int)
|
||||
func candidatePairRightClicked(at index: Int, action: CandidateContextMenuAction)
|
||||
func candidates(_ sender: Any!) -> [Any]!
|
||||
func candidateToolTip(shortened: Bool) -> String
|
||||
func resetCandidateWindowOrigin()
|
||||
@discardableResult func reverseLookup(for value: String) -> [String]
|
||||
var selectionKeys: String { get }
|
||||
|
|
Loading…
Reference in New Issue