Re: NSOutlineView - display NSButtonCell only for leaf node with outlineView:dataCellForTableColumn:item: method
Re: NSOutlineView - display NSButtonCell only for leaf node with outlineView:dataCellForTableColumn:item: method
- Subject: Re: NSOutlineView - display NSButtonCell only for leaf node with outlineView:dataCellForTableColumn:item: method
- From: Gilles Celli <email@hidden>
- Date: Mon, 03 Oct 2011 10:36:10 +0200
Quincey, thanks for the quick reply!
As you suggested I tried the different options (putting a button cell in IB) and also returning with a non-nil cell for the NSOutlineView…but I'm not quite sure what you mean:
Do I need to remove the "buttonColumn" and have only one column ? And then generate a NSButtonCell with an NSString generated from the OvItem name ?
If you have any code snippets this would be really great !
Thanks
--Gilles
>
> This is the correct basic approach, but there's no need to create a new cell every time this method is called. You can create it once, and return it whenever a cell of that kind is needed.
>
> If you're seeing the same result in every row, regardless of type, then it's your 'if' test that's suspect first of all. Have you verified that the correct path is taken through this code for all three types of row?
>
> Also, since (presumably) there are far more rows that *do* want to display the button cell than don't, you'd probably be better off reversing the logic. Set a button cell on the column in IB, and let [tableColumn dataCell] be the default. For the rows where you don't want the button, return a simple text cell instead. (You don't actually have to create this cell at all. You can use the one from the other column if you want. Any cell will do.)
>
> In fact, there's an even better choice. If you read the documentation for 'outlineView:dataCellForTableColumn:item:', you'll see that it's *first* called with a nil table column. If you return a non-nil cell, then that cell is used to draw the whole row. That's probably your best choice for drawing the non-leaf rows, since it won't even leave room where the button would be. Looks better that way, and it allows you to add as many detail columns as you without without mucking up your higher-level rows.
>
> Quincey
_______________________________________________
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