FROM : Nathan Vander Wilt
DATE : Wed Jul 02 22:20:36 2008
>> 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
DATE : Wed Jul 02 22:20:36 2008
>> 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
| Related mails | Author | Date |
|---|---|---|
| Nathan Vander Wilt | Jun 26, 20:20 | |
| Douglas Davidson | Jun 26, 20:56 | |
| Greg Titus | Jun 26, 21:17 | |
| Quincey Morris | Jun 26, 21:42 | |
| Michael Ash | Jun 26, 23:40 | |
| Nathan Vander Wilt | Jul 2, 22:20 |






Cocoa mail archive

