For other applications, like Dropbox and 1Password, the popover that opens when you click the NSStatusItem in the top bar automatically hides (and then reshows) if you open up Exposé/Mission Control with F3 to switch spaces.
How is this accomplished? I can't figure out a good way to listen for the F3 event like you can for left/right click, and 1Password works despite having Accessibility access enabled for something like this.
Thoughts?
This isn't a great answer, but I ended up abandoning NSPopover. NSWindow has an attribute 'collectionBehavior', which controls how the NSWindow behaves with respect to other spaces and Exposé. The behavior that I wanted (and that I noticed in 1Password and Dropbox) can be replicated with
window.collectionBehavior = [.transient, .ignoresCycle]
..transient
makes it so that when you open Exposé the window automatically hides, and re-opens when you close it, and.ignoresCycle
makes it not behave like a real window when toggling through windows. I then just present it when the NSStatusBar item is toggled, and hide it otherwise.