From 1c3eef64007f5278d8edadf5814ea15abba76c0a Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sat, 4 Jun 2022 14:03:36 +0800 Subject: [PATCH] ctlIME // Add ctlCandidateVertical pos for horizontal typing. --- Source/Modules/IMEModules/ctlInputMethod.swift | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/Modules/IMEModules/ctlInputMethod.swift b/Source/Modules/IMEModules/ctlInputMethod.swift index d84cf7c2..8b856e0c 100644 --- a/Source/Modules/IMEModules/ctlInputMethod.swift +++ b/Source/Modules/IMEModules/ctlInputMethod.swift @@ -458,16 +458,22 @@ extension ctlInputMethod { extension ctlInputMethod { private func show(candidateWindowWith state: InputState, client: Any!) { var isTypingVertical: Bool { - var isTypingVertical = false + if let state = state as? InputState.ChoosingCandidate { + return state.isTypingVertical + } else if let state = state as? InputState.AssociatedPhrases { + return state.isTypingVertical + } + return false + } + var isCandidateWindowVertical: Bool { var candidates: [String] = [] if let state = state as? InputState.ChoosingCandidate { - isTypingVertical = state.isTypingVertical candidates = state.candidates } else if let state = state as? InputState.AssociatedPhrases { - isTypingVertical = state.isTypingVertical candidates = state.candidates } if isTypingVertical { return true } + // 以上是通用情形。接下來決定橫排輸入時是否使用縱排選字窗。 candidates.sort { $0.count > $1.count } @@ -481,7 +487,7 @@ extension ctlInputMethod { ctlCandidateCurrent.delegate = nil - if isTypingVertical { + if isCandidateWindowVertical { // 縱排輸入時強制使用縱排選字窗 ctlCandidateCurrent.currentLayout = .vertical } else if mgrPrefs.useHorizontalCandidateList { ctlCandidateCurrent.currentLayout = .horizontal