TooltipUI // Auto-close out-of-date window instances.

This commit is contained in:
ShikiSuen 2023-09-05 15:38:47 +08:00
parent e22941e8ae
commit ff2df510d7
1 changed files with 7 additions and 0 deletions

View File

@ -20,6 +20,12 @@ public class TooltipUI: NSWindowController {
} }
} }
private static var currentWindow: NSWindow? {
willSet {
currentWindow?.orderOut(nil)
}
}
public var direction: NSAttributedTooltipTextView.writingDirection = .horizontal { public var direction: NSAttributedTooltipTextView.writingDirection = .horizontal {
didSet { didSet {
if #unavailable(macOS 10.13) { direction = .horizontal } if #unavailable(macOS 10.13) { direction = .horizontal }
@ -47,6 +53,7 @@ public class TooltipUI: NSWindowController {
messageText.textColor = NSColor.textColor messageText.textColor = NSColor.textColor
messageText.needsDisplay = true messageText.needsDisplay = true
panel.contentView?.addSubview(messageText) panel.contentView?.addSubview(messageText)
Self.currentWindow = panel
super.init(window: panel) super.init(window: panel)
} }