Grant Lucas
Grant Lucas

Reputation: 23

In Objective-C/Cocoa, are there global events for when mission control is activated or spaces are changed?

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.

Upvotes: 2

Views: 804

Answers (1)

CRD
CRD

Reputation: 53010

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

Upvotes: 2

Related Questions