Re: Lost ability to alt-drag IB items [Solved]
Re: Lost ability to alt-drag IB items [Solved]
- Subject: Re: Lost ability to alt-drag IB items [Solved]
- From: Ricky Sharp <email@hidden>
- Date: Fri, 10 Dec 2004 13:08:40 -0600
On Dec 10, 2004, at 8:54 AM, Ricky Sharp wrote:
I need to head out for a bit, but will follow up on this thread with
the minimal implementation one needs to do when deriving directly from
NSCell.
If you have a subclass of NSCell, you need to provide an implementation
for setTag: as NSCell will raise an exception in its implementation.
At the minimum, I've found that you should:
(1) Add the following iVar to your cell subclass:
int tag;
(2) Add -tag and -setTag: accessors.
(3) In your cell's designated initializer, initialize tag to something
(e.g. 0). I use my accessor to do this.
(4) In your encodeWithCoder and initWithCoder methods, encode/decode
this iVar.
(5) In your copyWithZone, make sure to copy this tag attribute.
(6) There's nothing you need to do to your NSControl subclass; it
already has default implementations of tag and setTag: that simply call
through to the cell's implementation.
(7) If you want to allow editing the value of the tag in IB, of course
add an appropriate control to your inspector.
Now then, it will take more work to have a system that will
automatically assign unique values to your tag when you drag out an
NSMatrix of such cells. But, at least you'll have the code in place
that will allow alt-dragging to work.
BTW, the main reason I overlooked this whole 'tag' thing was that none
of the docs on subclassing NSCell brought it up. I'll be filing a
documentation enhancement request later on to point out some of these
gotchas.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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