views:

288

answers:

1

I want to create an NSOutlineView subclass where some of the entries look like buttons. It would look something like this:

+ Fruits
  + Organic
    - Apples
    - Bananas
    [Add Item]
  + Non-organic
    - Cherries
    [Add Item]
  [Add Item]
+ Vegetables
  - Carrots
  [Add Item]

Where all of the "[Add Item]"'s are buttons.

I have a feeling this involves using the outlineView:willDisplayCell:forTableColumn:item: delegate method somehow?

+2  A: 

You'll want to implement the outlineView:dataCellForTableColumn:item: method in your outline view's delegate to return an NSButtonCell for the rows where you want a button, and an NSTextFieldCell for the other rows. Note that this delegate method was added in 10.5, if you need to support 10.4 or earlier, then you'll need to have a custom NSTableColumn subclass that overrides the dataCellForRow: method.

Brian Webster