mouse move event

Discussion in 'Mac Programming' started by printf, Oct 21, 2008.

  1. printf macrumors regular

    Joined:
    Aug 27, 2008
    #1
    i need a way to determine when a mouse moves over a certain area of my view, or its respective window - either is fine.

    currently i used kEventControlTrack in conjunction with TrackMouseLocation to capture click and drag events, but this obviously won't work for just the mouse movement itself.
     
  2. printf thread starter macrumors regular

    Joined:
    Aug 27, 2008
    #2
    ok, i got it working - for some reason i had to install a separate handler for the mouse events from the custom view events... weird

    i used these events to get it to work:

    EventTypeSpec mouse_events[] = {
    { kEventClassMouse, kEventMouseDown },
    { kEventClassMouse, kEventMouseMoved },
    { kEventClassMouse, kEventMouseUp }
    };

    maybe it was because these events are exclusive to windows? i passed the view reference to the installer and it didn't work, but then passed a window ref and it did.
     
  3. SydneyDev macrumors 6502

    Joined:
    Sep 15, 2008
    #3
    I did this recently using NSTrackingArea. You pass it an NSRect in your view co-ordinates and it gives you callbacks when the mouse enters or exits or moves within it. It is a 10.5 API though.
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    Just guessing, but it could be separate because mouse move events are so frequent and it doesn't want to send them unless necessary. It's kind of like this in Cocoa - you have to enable mouse move events at the window level to see them in a view.

    He's using Carbon ;)
     

Share This Page