Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

printf

macrumors regular
Original poster
Aug 27, 2008
105
0
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.
 

printf

macrumors regular
Original poster
Aug 27, 2008
105
0
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.
 

SydneyDev

macrumors 6502
Sep 15, 2008
346
0
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.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
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.

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.

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.

He's using Carbon ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.