On Jun 26, 2008, at 11:56 AM, Douglas Davidson wrote:


On Jun 26, 2008, at 11:20 AM, Nathan Vander Wilt wrote:

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.

Even though it seems like I'd be reimplementing something Cocoa already offers, I'm leaning towards option A: I'm not sure if I'll be able to foresee all the edge cases, and I'd be reinventing half the hit testing code there anyway. Does it sound reasonable from a maintenance and performance perspective to handle the mouse on my own inside my view? It seems like the tracking Cocoa provides is designed for more static content, or am I just missing the intended "Option C" recipe for my scenario?

If your hit testing is not too time-consuming, it is quite possible to do it on every mouse move. Individual tracking areas are convenient if you don't have your own hit-testing mechanism set up, but if you are able to do it efficiently yourself, you certainly may do so.

What we tend to do when we do hit-testing via mouse move is to also calculate and cache the rect within which the current state is valid. So then at the very top of your hit testing you can do a quick test: is the mouse still within the same area it was before? If so, don't need to do anything and return quickly. This can make hit testing a lot more efficient if you have complicated content.

        - Greg
_______________________________________________

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