Re: NSCell mouse tracking best practices.
Re: NSCell mouse tracking best practices.
- Subject: Re: NSCell mouse tracking best practices.
- From: Corbin Dunn <email@hidden>
- Date: Wed, 5 Jul 2006 20:23:16 -0700
My app (NotLight) uses an NSImageCell subclass. What I do is:
(1) I implement trackMouse:, as you say. (I don't use any instance
variable
for the tracking rectangle - I don't have to, because I'm not
creating a
draggable image - but I do set some state switches telling me
whether the
mouse is in a certain region.)
That's required for NSImageCell because it isn't meant to be tracked.
You have to do your own tracking (it, by default, just returns NO).
(2) In the NSMatrix subclass, I implement mouseUp and notify the
relevant
cells that the mouse went up. This sort of cooperation between the
NSMatrix
and the NSCells makes things very complicated, but for some purposes
that's
just the way you have to do it. My NSCell didn't get any
startTracking:...
(etc.) messages, and I assume that this is because it's an
NSImageCell.
That's why I had to resort to the matrix's mouseUp instead. m.
You shouldn't have to do this; you need to:
1. Return YES if you handled mouse up in your trackMouse: method.
2. Return YES from +prefersTrackingUntilMouseUp, which defaults to NO
for NSCell.
--corbin
PS: a plug for WWDC -- I'm giving an "Advanced Controls and Cells"
talk (called "Beyond Buttons") at WWDC this year. I'm covering the ins
and outs of this.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden