How would I use outlineView:isGroupItem:
to give the root object in an NSOutlineView a Gradient background?
views:
227answers:
1
+3
A:
You implement this in the outlineView's delegate.
One way of doing this:
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item {
if ([outlineView parentForItem:item]) {
// If not nil; then the item has a parent.
return NO;
}
return YES;
}
Here's a link to the docs.
Abizern
2009-09-19 21:15:24
Thanks. I expected that to work, but oddly after putting the code in my data source my outline view doesn't change at all, meaning that the root item still doesn't have the gradient background. Odd.
Joshua
2009-09-20 07:23:33
It's a delegate method, not a datasource method. Make sure that the tableview's delegate outlet is also connected to the datasource in this case.
Abizern
2009-09-20 09:21:14
Ah. I see. I've put it in the Delegate now (http://snapplr.com/fvzs). But what do you mean by 'Make sure that the tableview's delegate outlet is also connected to the datasource in this case.'
Joshua
2009-09-20 12:05:47
And it still doesn't work.
Joshua
2009-09-20 12:06:22
Outline views have a delegate outlet as well as a datasource outlet. You need to hook up the delegate outlet to the class that implements this method in IB. I've just run this in a sample app and it works for me. http://embr.it/Ro
Abizern
2009-09-20 13:29:50
Would you mind sending me a link to that Sample App?
Joshua
2009-09-20 15:51:48
Add the method to a table delegate in this sample app. http://developer.apple.com/mac/library/samplecode/AbstractTree/
Abizern
2009-09-20 20:16:31
Ah, I see. But how did you get the grey background not the default blue one?
Joshua
2009-09-21 05:47:53
I'm not sure what you mean. Have you tried setting the highlight style of the outline view to be Regular instead of Source view?
Abizern
2009-09-21 08:38:48
Don't worry it works. Thanks!
Joshua
2009-09-21 15:09:34