Mac Track mouse movement outside app's window

ranguvar

macrumors 6502
Original poster
Sep 18, 2009
318
1
Hi,

I'd like my app to track mouse movements even if the mouse no longer hovers above the app's window, but for example on the desktop or on other apps. Receiving a -mouseExited call is not enough, I have to know the actual position of the mouse on the screen.
Is this possible using an NSTrackingArea (if so, how)? Or do I have to use something else.

Thanks for any input!
 

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
1
Portland, OR
Better (but 10.6-only) way:
Code:
[NSEvent addGlobalMonitorForEventsMatchingMask:NSMouseMoved handler:^(NSEvent *mouseMovedEvent) {
 //do things with mouseMovedEvent
}];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.