SessionCtl // Change how updateVerticalTypingStatus() gets triggered.

This commit is contained in:
ShikiSuen 2022-12-14 14:45:33 +08:00
parent 00ce1f23ce
commit b64910d7a5
3 changed files with 8 additions and 9 deletions

View File

@ -106,14 +106,12 @@ public class SessionCtl: IMKInputController {
isVerticalTyping = false isVerticalTyping = false
return return
} }
DispatchQueue.main.async { var textFrame = NSRect.seniorTheBeast
var textFrame = NSRect.seniorTheBeast let attributes: [AnyHashable: Any]? = client.attributes(
let attributes: [AnyHashable: Any]? = client.attributes( forCharacterIndex: 0, lineHeightRectangle: &textFrame
forCharacterIndex: 0, lineHeightRectangle: &textFrame )
) let result = (attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false
let result = (attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false isVerticalTyping = result
self.isVerticalTyping = result
}
} }
/// InputMode /// InputMode
@ -213,7 +211,6 @@ extension SessionCtl {
public override func activateServer(_ sender: Any!) { public override func activateServer(_ sender: Any!) {
_ = sender // _ = sender //
DispatchQueue.main.async { [self] in DispatchQueue.main.async { [self] in
defer { updateVerticalTypingStatus() }
if let senderBundleID: String = (sender as? IMKTextInput)?.bundleIdentifier() { if let senderBundleID: String = (sender as? IMKTextInput)?.bundleIdentifier() {
vCLog("activateServer(\(senderBundleID))") vCLog("activateServer(\(senderBundleID))")
isServingIMEItself = Bundle.main.bundleIdentifier == senderBundleID isServingIMEItself = Bundle.main.bundleIdentifier == senderBundleID

View File

@ -73,6 +73,7 @@ extension SessionCtl {
public func showCandidates() { public func showCandidates() {
guard let client = client() else { return } guard let client = client() else { return }
updateVerticalTypingStatus()
state.isVerticalCandidateWindow = (isVerticalTyping || !PrefMgr.shared.useHorizontalCandidateList) state.isVerticalCandidateWindow = (isVerticalTyping || !PrefMgr.shared.useHorizontalCandidateList)
/// IMK /// IMK

View File

@ -119,6 +119,7 @@ extension SessionCtl {
// //
if event.isUp || event.isDown || event.isLeft || event.isRight { if event.isUp || event.isDown || event.isLeft || event.isRight {
updateVerticalTypingStatus() //
eventToDeal = event.reinitiate(charactersIgnoringModifiers: isVerticalTyping ? "Vertical" : "Horizontal") ?? event eventToDeal = event.reinitiate(charactersIgnoringModifiers: isVerticalTyping ? "Vertical" : "Horizontal") ?? event
} }