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

StackOverflow https://stackoverflow.com/questions/22513783

Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top