From 4888a0dc547f49103061273a0d41b7c8eba3c00e Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 29 May 2023 21:22:15 +0800 Subject: [PATCH] SessionCtl // Use annotationSelected(). --- Source/Modules/SessionCtl_IMKCandidatesData.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Modules/SessionCtl_IMKCandidatesData.swift b/Source/Modules/SessionCtl_IMKCandidatesData.swift index 39250fd6..cb5b5014 100644 --- a/Source/Modules/SessionCtl_IMKCandidatesData.swift +++ b/Source/Modules/SessionCtl_IMKCandidatesData.swift @@ -70,19 +70,22 @@ public extension SessionCtl { /// - Parameter currentSelection: 已經高亮選中的候選字詞內容。 override func candidateSelectionChanged(_ currentSelection: NSAttributedString!) { guard let candidateString = currentSelection?.string, !candidateString.isEmpty else { return } + // Handle candidatePairHighlightChanged(). + var indexDeducted = 0 + fixIndexForIMKCandidates(&indexDeducted, source: candidateString) + if state.type == .ofCandidates { + candidatePairHighlightChanged(at: indexDeducted) + } + let realCandidateString = state.candidates[indexDeducted].value // Handle IMK Annotation... We just use this to tell Apple that this never works in IMKCandidates. DispatchQueue.main.async { [self] in let annotation = reverseLookup(for: candidateString).joined(separator: "\n") guard !annotation.isEmpty else { return } vCLog("Current Annotation: \(annotation)") guard let imkCandidates = candidateUI as? CtlCandidateIMK else { return } + annotationSelected(.init(string: annotation), forCandidate: .init(string: realCandidateString)) imkCandidates.showAnnotation(.init(string: annotation)) } - // Handle candidatePairHighlightChanged(). - guard state.type == .ofCandidates else { return } - var indexDeducted = 0 - fixIndexForIMKCandidates(&indexDeducted, source: candidateString) - candidatePairHighlightChanged(at: indexDeducted) } /// IMK 選字窗限定函式,只要選字窗確認了某個候選字詞的選擇、就會呼叫這個函式。