For my small Mac menubar application I'd like the behavior of the popover to be transient, so when it loses focus, it will close. This works for that:
popover.behavior = NSPopoverBehavior.Transient
But it only works once, so the second time you click somewhere else the popover stays. I placed the code in func applicationDidFinishLaunching(notification: NSNotification)
, but placing it outside this function inside the class did not work. How can I use force this behavior all the time?
I am using Xcode 7.0 with Swift (2.0).