Is there a way to register for global mouse moved events in Cocoa? I was able to register for the events using Carbon's InstallEventHandler()
, but would prefer a Cocoa equivalent. I have looked for NSNotificationCenter
events, but there doesn't seem to be any public event names (are there private ones?)
Alternatively, is there a way to use NSTrackingArea
for views with a clearColor
background?
The app is Snow Leopard only.
In SnowLeopard there is a new class method on NSEvent
which does exactly what you want: + (id)addGlobalMonitorForEventsMatchingMask:(NSEventMask)mask handler:(void (^)(NSEvent*))block
. You’ll want mask = NSMouseMovedMask
.