NSPopover Close behaviour when entering Mission Control or LaunchPad

Geoff Coope asked about the close: behaviour of the NSPopover when entering Mission Control in the comments  of my previous post   Epiphany-for-fixing-nspopover .

He had noticed that the Popovers did not close when you entered into Mission Control

This was not something I had noticed as I had never gone into Mission Control with a popover open.  But he was right and not only in Mission Control, entering  Launchpad also does not close the Popover.

I had just been using a notification to control a NSDocuments behaviour and had an idea that the same thing could work.

But first tried to find if there was a documented way of detecting when you enter Mission Control  or Launchpad.  Nope nothing I could find.

So my next step..

In your  : – (void)applicationDidFinishLaunching:(NSNotification *)aNotification place a NSObserver that will detect when the key window has resigned key. And point it to a method that will be called when the notification fires.

The resignKey: method  calls for the popover to close in the normal way:  [_popover close];


For NSPopovers that are in the status bar menu.  The window you use does not have to  exist in the  nib. It seems you just need to declare a NSWindow in  properties :    @property (assign) IBOutlet NSWindow *window;

And  use that. It works ( ???)



application Did Finish Launching

– (void)applicationDidFinishLaunching:(NSNotification *)aNotification


    [[NSNotificationCenter defaultCenter] addObserver : self selector:@selector (resignKey:) name:NSWindowDidResignKeyNotification object: _window ];


Resign key method

– (void)resignKey:(NSNotification *)notification {


    [_popover close];




This simple control  worked for LaunchPad… but alas not Mission Control.

Looking at Apples implementation of an NSpopover in Safari the behaviour is the same.  Click and  open the downloads popover in Safari and you will see it does the same thing we are seeing

So still need to figure out the  Mission Control.. but do not hold out much hope.

20 Replies to “NSPopover Close behaviour when entering Mission Control or LaunchPad”

  1. Sounds good! I’ll definitely post a link to the repository once I’m done a sample app that people can use.
    I’ll wait for your email,

  2. I can reply directly to you so you get it. ( if thats ok with you ) Use that for the zip. But post on the site any updates so others can see them.

  3. This is true, it could be an NSPanel or NSWindow. It’s definitely not a menu from what I can tell though. It has that little arrow thing pointing towards the status bar item instead of coming out flush like a menu.
    Where can I find your email?

  4. Thanks I will have a look at that when i get a min. You can email me the zip. Bear in mind that Dropbox may not be using a NSPopover.

  5. Just came across another solution that seems to work perfectly for all cases *EXCEPT* mission control…

    Add this property to the file that contains the logic for your popover
    @property (strong, nonatomic) NSEvent *popoverTransiencyMonitor;

    And add the following code immediately after the line where you open your popover:

    if (self.popoverTransiencyMonitor == nil) {
    self.popoverTransiencyMonitor = [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDownMask | NSRightMouseDownMask | NSKeyUpMask) handler:^(NSEvent* event) {
    [NSEvent removeMonitor:self.popoverTransiencyMonitor];
    self.popoverTransiencyMonitor = nil;
    [self.popover close];

    This fixed my issues with the popover occasionally getting stuck open, however it doesn’t fix the issue with it appearing over everything in mission control. I examined how the popover that Dropbox implements works, and though it does close the popover when you enter launchpad, it doesn’t actually close when you enter mission control, it fades away and comes back when you close mission control. Maybe this can help someone find a way to get that sort of functionality? As of right now this is my only remaining bug… When I enter mission control the popover is layered over the mission control view instead of fading away nicely…

    As soon as I have all this functionality figured out I will most likely upload a sample app that people can use to start status bar apps to avoid having to scrounge the interwebs for fixes like I currently am. As of yet I haven’t found anything to address this last issue but I know it can be done if dropbox did it!

  6. Could I email you a zip of the project? There isn’t much to it other than the menubar item and the popover. Just have to get this basic functionality going before I move on to the actual project?

    Thanks for the quick reply!!

  7. Hey, I’m running into a tiny bug with your solutions and can’t for the life of me figure out why this is happening…

    I have a menu bar item that opens a small popover and I’ve been trying to get it to dismiss properly when any action is taken outside of it.

    If you open the popover, then open launch control, the popover will close, however upon opening popover again, the only way to close it is by clicking the menubar item. Once you close it like this however, the next time you open it everything is fine, it closes properly, unless it gets closed via the launchpad triggering it. Then it breaks it the next time you use it.

    Essentially every time the popover gets closed by entering launchpad, the next time you launch the popover nothing but clicking the menu bar item will close it that time.

    I’ve tried using performClose:self instead of just close to close the popover via launchpad but that hasn’t helped… I’m at a loss here. This is a very minor bug but very annoying now that I know it’s there…
    Any insight?

  8. I have gone through loads of notifications trying to get keyboard key “F3” (Launch Control key) to dismiss my popover but at a loss still. Thanks for your help though, I keep learning all the time 🙂

Hi, Please Leave a Reply