Re: mouse entered/exited in nscollectionviewitem's view
Re: mouse entered/exited in nscollectionviewitem's view
- Subject: Re: mouse entered/exited in nscollectionviewitem's view
- From: Benjámin Salánki <email@hidden>
- Date: Sat, 25 Jul 2009 18:36:10 +0200
On Jul 24, 2009, at 3:23 PM, Keith Duncan wrote:
the setup code only gets called once and then none of the actually
displayed views in the collection handle any of my intended mouse
tracking.
That's probably because your subclass of NSCollectionViewItem isn't
getting created for each item. You can override -copyWithZone: to
confirm this and fix it if need be.
It's also prudent to ask for the mouse moved events to be sent too.
Thanks, after doing this I managed to get the results I was looking for!
Could anyone please point me into the right direction where to go
on from here?
Any help is appreciated.
Yes, you'll also run into a problem when the user uses the scroll
wheel to move around the collection view. The fix for this one is
slightly more in depth.
Your view under the mouse will first be send -scrollWheel: and it
will work it's way up the responder chain to the scroll view from
there. I inserted my NSCollectionViewItem subclass into the
responder chain between the item view and it's superview so that the
controller was sent -scrollWheel: before the scroll view.
And how would you go on about doing this? I just spent a couple hours
trying to find a workaround myself, but failed. I have the mouse
position tracking code up and running, but I guess it does not get
called at the right time.
Ben
In that method I tracked the position of the mouse converting from
window coordinates to collection view coordinates and determined
which view the mouse was hovering over. Once you've done that it's a
simple matter of posting a notification internal to the collection
view item subclass to coordinate the hovering state between
controllers so that only one is showing the hovering state at a
given time.
Keith
_______________________________________________
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