2

I'm currently working on an OSX menubar app that uses a custom status item view and a NSPopover to display content.

I'm trying to get it to dismiss at times that would make sense like when spaces are changed, since the popover doesn't move spaces like a window does, or when mission controller is activated.

Currently, when in mission control, the NSPopover stays on top as shown in this screenshot.

Currently I'm using NSEvent addGlobalMonitorForEventsMatchingMask: with some mouse event masks and that works alright but doesn't cover all needed events.

So, is there a way to detect when major OS events happen like opening mission control, changing spaces etc?

Any help would be greatly appreciated.

1
  • I've also tried using NSPopoverBehaviorTransient but I lost some needed control when the popup closes. Just adding that bit on info for completion sake. Mar 19, 2014 at 19:46

1 Answer 1

2

You can get notified of space changes by registering for NSWorkspace's NSWorkspaceActiveSpaceDidChangeNotification. There isn't a notification as such for Mission Control, but you might investigate whether NSWorkspaceDidActivateApplicationNotification or other notifications can be used to determine what you need.

HTH

1
  • Awesome. Thanks for your help! NSWorkspaceActiveSpaceDidChangeNotification Worked perfectly for space changes! So far I haven't been able to find anything for Mission Control but I'm getting close to the point of abandoning NSPopover for a panel or window instead. Mar 19, 2014 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.