Re: NSCell mouse tracking best practices.
Re: NSCell mouse tracking best practices.
- Subject: Re: NSCell mouse tracking best practices.
- From: Ricky Sharp <email@hidden>
- Date: Thu, 06 Jul 2006 06:47:52 -0500
On Wednesday, July 05, 2006, at 10:23PM, Corbin Dunn <email@hidden> wrote:
>> (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.
I think in some cases you have to implement mouse handling in a NSMatrix subclass.
For my custom UI, I fought quite a bit with the framework when wanting to implement a radio group. At first, I tried a standard NSMatrix with a subclass of NSButtonCell. Due to failures**, I then tried a subclass of NSActionCell. But that still failed. The only solution I could come up with was to subclass NSMatrix as well as NSActionCell. Tracking was then handled via implmentations in both classes. I was able to achieve proper tracking behavior (with or without keyboard focus) and integrate built-in and custom bindings.
** I was not able to obtain proper tracking behavior with respect to the keyboard focus. Setup: You have full keyboard access turned on, have a radio group such that radio #1 is selected and has the keyboard focus. When you mouse down on radio #2, it will begin tracking and the keyboard focus will change to the radio being tracked. If you then release the mouse outside radio #2's bounds, the keyboard focus "snaps back" to radio #1.
There were a few other subtle behaviors too that I could not achieve with any tracking mode of NSMatrix paired up with a subclass of NSButtonCell or NSActionCell. While there are very good hooks (I think newer APIs came in with 10.4), to allow one to provide custom drawing of controls, it seemed that tracking behavior would be somehow different. This led me to believe that there is quite a bit of coupling between NSMatrix and NSButtonCell and that any other combo of classes would require a custom tracking implementation.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
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