I\'m using the doubleClickAction
of a NSTableView
to display a NSPopover
. Something like this:
NSInteger selectedRow = [da
You need to change the property behavior of your popover (in code or on interface builder) to:
popover.behavior = NSPopover.Behavior.transient;
NSPopover.Behavior.transient
The system will close the popover when the user interacts with a user interface element outside the popover.
Read more about this in Apple's documentation.
the .transient
flag doesn't work for me.
However I can make things work by the following:
1) Whenever I show my popover I make sure I activate the app (my app is a menu-bar app, so this doesn't happen automatically)
NSApp.activate(ignoringOtherApps: true)
2) When I click outside the app, then my app will be deactivated. I can detect this in the AppDelegate
func applicationWillResignActive(_ notification: Notification) {
print("resign active")
}
and act accordingly