Good mouse tracking design for dynamic view?
Good mouse tracking design for dynamic view?
- Subject: Good mouse tracking design for dynamic view?
- From: Nathan Vander Wilt <email@hidden>
- Date: Thu, 26 Jun 2008 11:20:54 -0700
I have a view that displays and allows interaction with a lot
(hundreds, even thousands) of small items. I am having trouble nailing
down a good design for event handling, and just as I was ready to
plead for help I see some other NSTrackingArea discussion that perhaps
sheds a little light, but still inconclusive.
It seems tidy to clear and reset all my tracking areas as the view
gets redrawn, but that leads to situations like where an item moves
relative to the mouse instead of vice versa, and since tracking areas
can't be moved, the mouseEntered->mouseExited transaction gets killed
halfway through with the old tracking area.
My problem is that the displayed items can get updated (moved,
deleted, etc.) in situations like this:
1. The user mouses over an item, its tracking area fires, and some
status text elsewhere gets set to reflect what's under the mouse.
2. Before the mouse moves away from the item, the item moves and its
previous tracking area is deleted. So now I never get that mouse
exited event, even though the status text should be cleared.
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?
thanks,
-natevw
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden