Re: Custom NSCells
Re: Custom NSCells
- Subject: Re: Custom NSCells
- From: "Michael Ash" <email@hidden>
- Date: Sun, 13 Jul 2008 23:46:05 -0400
On Sun, Jul 13, 2008 at 6:59 PM, Paul Williams <email@hidden> wrote:
> Hi,
>
> I am trying to find a way where I can use a NSTableView to display a list of
> buttons(NSButtonCell) which can be hidden depending on the state of the
> program.
> I have tried using a custom NSCells, but the only object I can can pass to
> my custom cell is a NSCFBoolean.
> Is there a way I can pass more information to my custom cell so I can have a
> button which can be set to On,Off or hidden.
There are two ways to give more information to your custom cell:
- Use an NSDictionary or an instance of a custom class as your object
value. If you're using a data source, return this object in your
objectValueForTableColumn method. If you're using bindings, bind the
array to a key path which produces this object. In both cases, this
dictionary or custom object will be passed to your cell's
-setObjectValue: method, and then you can do whatever you want with
its contents.
- Implement the willDisplayCell delegate method. This method is called
just before the cell is displayed, and at that point you can do
whatever you want to it based on the column/row information provided.
Depending on exactly what you need, you may not even need to implement
an NSCell subclass if you use this approach, if you can customize
NSButtonCell sufficiently.
Mike
_______________________________________________
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