diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_Cocoa.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_Cocoa.swift index eed996f0..d1e72ef6 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_Cocoa.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_Cocoa.swift @@ -386,7 +386,7 @@ private extension VwrCandidateTDKCocoa { private extension VwrCandidateTDKCocoa { func didSelectCandidateAt(_ pos: Int) { - controller?.delegate?.candidatePairSelected(at: pos) + controller?.delegate?.candidatePairSelectionConfirmed(at: pos) } func didRightClickCandidateAt(_ pos: Int, action: CandidateContextMenuAction) { diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_SwiftUI.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_SwiftUI.swift index 7ff1a548..de38d0b1 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_SwiftUI.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/TDKCandidates/VwrCandidateTDK_SwiftUI.swift @@ -350,7 +350,7 @@ extension VwrCandidateTDK { @available(macOS 10.15, *) private extension VwrCandidateTDK { func didSelectCandidateAt(_ pos: Int) { - controller?.delegate?.candidatePairSelected(at: pos) + controller?.delegate?.candidatePairSelectionConfirmed(at: pos) } func didRightClickCandidateAt(_ pos: Int, action: CandidateContextMenuAction) { diff --git a/Packages/vChewing_Shared/Sources/Shared/Protocols/CtlCandidateProtocol.swift b/Packages/vChewing_Shared/Sources/Shared/Protocols/CtlCandidateProtocol.swift index 8a86522d..7e8e96f4 100644 --- a/Packages/vChewing_Shared/Sources/Shared/Protocols/CtlCandidateProtocol.swift +++ b/Packages/vChewing_Shared/Sources/Shared/Protocols/CtlCandidateProtocol.swift @@ -10,7 +10,8 @@ import Cocoa public protocol CtlCandidateDelegate { func candidatePairs(conv: Bool) -> [(keyArray: [String], value: String)] - func candidatePairSelected(at index: Int) + func candidatePairSelectionConfirmed(at index: Int) + func candidatePairHighlightChanged(at index: Int) func candidatePairRightClicked(at index: Int, action: CandidateContextMenuAction) func candidates(_ sender: Any!) -> [Any]! @discardableResult func reverseLookup(for value: String) -> [String] diff --git a/Source/Modules/InputHandler_Core.swift b/Source/Modules/InputHandler_Core.swift index c3675e4d..ee753b00 100644 --- a/Source/Modules/InputHandler_Core.swift +++ b/Source/Modules/InputHandler_Core.swift @@ -66,7 +66,7 @@ public protocol InputHandlerDelegate { func updateVerticalTypingStatus() func switchState(_ newState: IMEStateProtocol) func candidateController() -> CtlCandidateProtocol? - func candidateSelectionCalledByInputHandler(at index: Int) + func candidateSelectionConfirmedByInputHandler(at index: Int) func performUserPhraseOperation(addToFilter: Bool) -> Bool } diff --git a/Source/Modules/InputHandler_HandleCandidate.swift b/Source/Modules/InputHandler_HandleCandidate.swift index 8a9a4035..5fd10221 100644 --- a/Source/Modules/InputHandler_HandleCandidate.swift +++ b/Source/Modules/InputHandler_HandleCandidate.swift @@ -62,7 +62,7 @@ extension InputHandler { delegate.switchState(IMEState.ofAbortion()) return true } - delegate.candidateSelectionCalledByInputHandler(at: ctlCandidate.highlightedIndex) + delegate.candidateSelectionConfirmedByInputHandler(at: ctlCandidate.highlightedIndex) return true case .kTab: let updated: Bool = @@ -142,7 +142,7 @@ extension InputHandler { if index != NSNotFound { if let candidateIndex = ctlCandidate.candidateIndexAtKeyLabelIndex(index) { - delegate.candidateSelectionCalledByInputHandler(at: candidateIndex) + delegate.candidateSelectionConfirmedByInputHandler(at: candidateIndex) return true } } @@ -185,7 +185,7 @@ extension InputHandler { if shouldAutoSelectCandidate { guard let candidateIndex = ctlCandidate.candidateIndexAtKeyLabelIndex(0) else { return true } - delegate.candidateSelectionCalledByInputHandler(at: candidateIndex) + delegate.candidateSelectionConfirmedByInputHandler(at: candidateIndex) delegate.switchState(IMEState.ofAbortion()) return handleInput(event: input) } diff --git a/Source/Modules/SessionCtl_Delegates.swift b/Source/Modules/SessionCtl_Delegates.swift index 3f19d6f6..2068e7f5 100644 --- a/Source/Modules/SessionCtl_Delegates.swift +++ b/Source/Modules/SessionCtl_Delegates.swift @@ -22,8 +22,8 @@ extension SessionCtl: InputHandlerDelegate { public func candidateController() -> CtlCandidateProtocol? { candidateUI } - public func candidateSelectionCalledByInputHandler(at index: Int) { - candidatePairSelected(at: index) + public func candidateSelectionConfirmedByInputHandler(at index: Int) { + candidatePairSelectionConfirmed(at: index) } public func callError(_ logMessage: String) { @@ -108,7 +108,9 @@ extension SessionCtl: CtlCandidateDelegate { return convertedCandidates } - public func candidatePairSelected(at index: Int) { + public func candidatePairHighlightChanged(at _: Int) {} + + public func candidatePairSelectionConfirmed(at index: Int) { guard let inputHandler = inputHandler else { return } if state.type == .ofSymbolTable, (0 ..< state.node.members.count).contains(index) { let node = state.node.members[index] diff --git a/Source/Modules/SessionCtl_IMKCandidatesData.swift b/Source/Modules/SessionCtl_IMKCandidatesData.swift index 1b39945d..69abe2b5 100644 --- a/Source/Modules/SessionCtl_IMKCandidatesData.swift +++ b/Source/Modules/SessionCtl_IMKCandidatesData.swift @@ -80,6 +80,7 @@ public extension SessionCtl { } /// IMK 選字窗限定函式,只要選字窗確認了某個候選字詞的選擇、就會呼叫這個函式。 + /// - Remark: 不要被 IMK 的 API 命名方式困惑到。這其實是 Confirm Selection 確認選字。 /// - Parameter candidateString: 已經確認的候選字詞內容。 override func candidateSelected(_ candidateString: NSAttributedString!) { let candidateString: String = candidateString?.string ?? "" @@ -150,6 +151,6 @@ public extension SessionCtl { handleIMKCandidatesSelected(state.candidates) } } - candidatePairSelected(at: indexDeducted) + candidatePairSelectionConfirmed(at: indexDeducted) } }