So it seems I need to do more bookwork myself, but I'm wondering which
direction others would recommend:
a) Set up a single tracking area for the whole view, and perform all my own
hit testing every time the mouse moves.
b) Keep the per-item tracking areas, but perform my own testing in the edge cases when active (mouse has entered but not exited) tracking areas are
getting reset.

I vote for option A.

Efficiency should not be a concern. [...]

Reinventing hit testing shouldn't be much of a concern either [...]


Thanks all for your encouragement. Implementing it myself isn't a problem (the rest of the code is pretty geometry heavy, so it's certainly not foreign territory) and has already made it easier to implement (or at least try out) other ideas, like finding everything within a certain radius of the cursor rather than just under.

I just put a single tracking area across the entire view bounds (with the NSTrackingInVisibleRect, which I understand to make the tracking area's "frame" rect irrelevant anyway) and just run a linear search noting all items under the mouse every time it moves. I then compare this to a list from the previous check, and notify the items that have changed of an exit/entrance accordingly. I haven't tested performance with a ton of items, but as not a great amount of work is done I don't foresee any problem.

I had to do one little "hack" for when the view itself is exited, namely, when the whole-view tracking area is exited I need to manually "exit" all items. Otherwise when the final mouseMoved fired, some items could still be underneath the mouse and would remain "entered". Only really hackish in the sense that I need two functions to update the active items and post pseudo-events, rather than just the one.

thanks,
-natevw
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to