How to programmatically detect that Mission Control is running?
How to programmatically detect that Mission Control is running?
- Subject: How to programmatically detect that Mission Control is running?
- From: Daiwei Li <email@hidden>
- Date: Tue, 02 Oct 2012 00:06:55 -0700
Hello all,
I posted this question on StackOverflow
here<http://stackoverflow.com/questions/12683225/osx-how-to-detect-if-mission-control-is-running>,
but I thought this list would also be an appropriate place. I've reproduced
the description of the problem I'm having below:
When Mission Control runs, it prevents applications from receiving keyboard
and mouse events. It also leaves the last application running thinking that
it still has focus. This is a problem for me because I don't receive keyUp
or mouseUp events if I start Mission Control with a mouse button or a key
held down and my application will behave as if that mouse button or key is
held down.
I would like a way to either read both keyboard and mouse events even when
Mission Control is active, or a way of detecting that Mission Control is
active. Ideally, I would like to be able to do the latter since I
effectively can't use my application when Mission Control is running.
I've tried a couple of things with no luck:
1. Use addGlobalMonitorForEventsMatchingMask to register a global
monitor for keyboard and mouse events. This captures mouse events (but not
keyboard events, although the
documentation<http://developer.apple.com/library/mac/#DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSEvent_Class/Reference/Reference.html#//apple_ref/c/econst/NSLeftMouseUp>
says
keyDown events should be sent to the global monitor) when I switch to
another application, but Mission Control doesn't seem to let events
propagate to global monitors.
2. Check [[NSRunningApplication currentApplication] {isActive,
ownsMenuBar}]. Apparently, my application is active even though it's not
receiving events!
3. Check [NSApp keyWindow] != nil. Apparently, one of my windows should
be receiving key events. None of them are.
4. Check if Mission Control is one of the running applications returned
by [NSWorkspace runningApplications]. Mission Control does not show up
in this list when it's running.
Thanks in advance!
Daiwei
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden