Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,23 @@ public class CandidateController: NSWindowController {
@objc public var selectedCandidateIndex: UInt = .max
@objc public var visible: Bool = false {
didSet {
NSObject.cancelPreviousPerformRequests(withTarget: self)
guard let window else {
return
}
let alreadyVisible = window.isVisible
if visible {
window.perform(#selector(NSWindow.orderFront(_:)), with: self, afterDelay: 0.0)
DispatchQueue.main.async {
window.orderFront(self)
}
if !alreadyVisible {
NSAccessibility.post(element: window, notification: .created)
NSAccessibility
.post(element: window, notification: .focusedWindowChanged)
}
} else {
window.perform(#selector(NSWindow.orderOut(_:)), with: self, afterDelay: 0.0)
DispatchQueue.main.async {
window.orderOut(self)
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/InputMethodController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,6 @@ extension McBopomofoInputMethodController {
gCurrentCandidateController?.reloadData()
currentClient = client

gCurrentCandidateController?.visible = true

var lineHeightRect = NSMakeRect(0.0, 0.0, 16.0, 16.0)
var cursor: Int = 0

Expand Down Expand Up @@ -829,6 +827,8 @@ extension McBopomofoInputMethodController {
lineHeightRect.origin.x, lineHeightRect.origin.y - 4.0),
bottomOutOfScreenAdjustmentHeight: lineHeightRect.size.height + 4.0)
}

gCurrentCandidateController?.visible = true
}

private func show(tooltip: String, composingBuffer: String, cursorIndex: UInt, client: Any!) {
Expand Down