Track mouse movement outside app's window

Discussion in 'Mac Programming' started by ranguvar, Nov 27, 2009.

  1. ranguvar macrumors 6502

    Joined:
    Sep 18, 2009
    #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!
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
  3. ranguvar thread starter macrumors 6502

    Joined:
    Sep 18, 2009
    #3
  4. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #4
    Better (but 10.6-only) way:
    Code:
    [NSEvent addGlobalMonitorForEventsMatchingMask:NSMouseMoved handler:^(NSEvent *mouseMovedEvent) {
     //do things with mouseMovedEvent
    }];
    
     
  5. ehunt123 macrumors newbie

    Joined:
    Dec 7, 2009
    #5

Share This Page