On Apr 20, 2009, at 16:03, Erik Österlund wrote:
So is there any difference at all between using NSPointInRect on the mouseMoved: event instead of using tracking rects? I mean, the events would have been sent anyway, if I understood this correctly. Then it would also be much easier to dynamically determine which object should be activated and choose whatever rules you want.
If all you want to do is know where mouse is, then using old-style mouseMoved events is much safer than using tracking rects. But the drawback (as spelled out in the NSWindow documentation) the drawback is that old-style mouseMoved events are spewed out indiscriminately, so long as setAcceptsMouseMovedEvents: YES is in effect for the window.
If you don't need to support Tiger, tracking areas are a better solution.
Are the "new-style" mouseMoved events the same then, except they are sent only when mouse is over the area, while "old-style" were sent all the time?
Basically, yes. Well, the new-style events can also tell you which tracking area they were generated for.
I thought the point with having tracking rects/areas would be to lower the amount of events sent, and send them only when mouse entered or exited the area.
It would have been the point, if tracking rects ever had the capability of limiting the number of mouseMoved events. But they don't, and that is one of their deficiencies.
I suppose that is for the mouseMoved: event, so does the same go for mouseDragged: events? They seem to be both related and unrelated somehow since they have the same kind of behaviour but do not need to be activated to be sent...
Nope, mouseDragged events are different. They're generated while the mouse is down, and are sent to the view that the mouseDown was sent to. Old-style mouseMoved events (if enabled) are not sent while the mouse is down. New-style mouseMoved events (if enabled during dragging by the NSTrackingEnabledDuringMouseDrag option) are sent while the mouse is down.
If this is an OpenGL-view and it has no subviews, but I'd like to have the subview behaviour, would the best approach be to just manually handle events as mentioned earlier, use layers with tracking areas somehow, or perhaps a completely different solution?
It's hard to say in general. NSTrackingArea is fairly easy to get started with, so I'd suggest you just experiment to find the best approach for you.
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com