views:

140

answers:

2

I am using an NSOutlineView in my App so i downloaded Apples Photo Search Sample App which uses an NSOutlineView. While using it I noticed that it gives the root object of the outline view a Gradient Background, so I looked through the code but I couldn't see what did it. Would someone mind looking through the code and then telling me what code gave the root object a background?

Here's the link to the Photo Search Download Page - http://developer.apple.com/Samplecode/PhotoSearch/index.html

Thanks!

A: 

It's outlineView:dataCellForTableColumn:item: in MainWindowController, which returns the cell created and assigned to iGroupRowCell by awakeFromNib. (No it is not. See my other answer, and please downvote this one.)

It seems as though NSOutlineView is giving the text field cell that style automatically. It definitely is that cell, as you can tell by setting its text color to red as soon as it's created.

If I'm wrong, then I'm stumped as to how it gets that style; if I'm right, it's a really cool feature.

Peter Hosey
Thanks. Is this the Part you're talking about http://www.grabup.com/uploads/d82201155f6d3f4fad8670f070ef81c7.png?direct. If so, How would I change that code to make it work in a Different Outline View?
Joshua
Yes. You would read it, and understand how it works, and then do the same thing in your own code.
Peter Hosey
You would not need the whole `if` thing as I just want it to have the background permanently. I would just want it to return iGroupRowCell always. Right?
Joshua
Maybe Not. Would I have change what's after `isKindOfClass:` to something else, to tell whether it's the header/root row?
Joshua
+4  A: 

OK, my previous answer is wrong. Here's the correct answer:

Be the outline view's delegate, and respond to outlineView:isGroupItem: (tableView:isGroupRow: for a non-outline table view) with YES if the item (row) is a group and should be displayed accordingly.

You mentioned in one of your comments on my other answer that you want to make every row look like a group. Don't do that; it will confuse users (“why does it have an empty group for every one of my items?”).

Peter Hosey
Thanks! That works!
Joshua