CtlCandidateTDK // Reset window origin on updateDisplay().

This commit is contained in:
ShikiSuen 2023-06-17 14:42:08 +08:00
parent 20368fcd91
commit e5c7505bdd
1 changed files with 19 additions and 13 deletions

View File

@ -106,22 +106,27 @@ public class CtlCandidateTDK: CtlCandidate, NSWindowDelegate {
}
delegate?.candidatePairHighlightChanged(at: highlightedIndex)
DispatchQueue.main.async { [self] in
window.isOpaque = false
window.backgroundColor = .clear
viewCheck: do {
viewCheckCatalina: if #available(macOS 10.15, *) {
if useCocoa { break viewCheckCatalina }
Self.thePool.update()
Self.currentView = NSHostingView(rootView: theView)
break viewCheck
}
Self.currentView = theViewCocoa
}
window.contentView = Self.currentView
window.setContentSize(Self.currentView.fittingSize)
updateNSWindowModern(window)
}
}
func updateNSWindowModern(_ window: NSWindow) {
window.isOpaque = false
window.backgroundColor = .clear
viewCheck: do {
viewCheckCatalina: if #available(macOS 10.15, *) {
if useCocoa { break viewCheckCatalina }
Self.thePool.update()
Self.currentView = NSHostingView(rootView: theView)
break viewCheck
}
Self.currentView = theViewCocoa
}
window.contentView = Self.currentView
window.setContentSize(Self.currentView.fittingSize)
delegate?.resetCandidateWindowOrigin()
}
func updateNSWindowLegacy(_ window: NSWindow) {
window.isOpaque = true
window.backgroundColor = NSColor.controlBackgroundColor
@ -139,6 +144,7 @@ public class CtlCandidateTDK: CtlCandidate, NSWindowDelegate {
Self.currentView.addSubview(viewToDraw)
window.contentView = Self.currentView
window.setContentSize(outerSize)
delegate?.resetCandidateWindowOrigin()
}
override public func scrollWheel(with event: NSEvent) {