I'm building a little status bar app, when i click the icon it shows a NSPopover. All worked fine till i upgraded to El Capitan. The problem is when i first launch the app, i simulate the status bar icon press automatically because i want to see the popover, and it appears in the lower left corner of the screen. After i close it and open again it appears alright from the top of the screen. Do you see anything wrong? This is the code and when i print the values in showPopover there's nothing wrong
private let menu = MenuBarController()
override init() {
super.init()
self.menu.onMouseDown = {
if (self.menu.iconView?.isSelected == true) {
self.showPopover()
} else {
self.hidePopover()
}
}
}
func showPopover() {
let icon = self.menu.iconView!
let edge = NSRectEdge.MinY
let rect = icon.frame
self.popover?.showRelativeToRect(rect, ofView: icon, preferredEdge: edge);
}
func applicationDidFinishLaunching(aNotification: NSNotification) {
let icon = self.menu.iconView!
icon.mouseDown(NSEvent())
}
Also, if i simulate the icon press after a small delay it works.
This works
func applicationDidFinishLaunching(aNotification: NSNotification) {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
popover.show(relativeTo: button.bounds, of: button, preferredEdge: .minY)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With