I am trying to figure out how to change the style for group nodes in NSOutlineView. With setSelectionHighlightStyle I can change the whole list style. But I want to change only the style for group nodes. How can I do that?
+3
A:
NSOutlineView
is a subclass of NSTableView
. Implement the tableView:willDisplayCell:forTableColumn:row:
in the NSOutlineView
delegate.
In the tableView:willDisplayCell:forTableColumn:row:
implement something like this:
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
if ([aTableView isGroupRow: rowIndex]) {
//modify aCell
}
}
Benedict Cohen
2009-09-11 15:37:39
+2
A:
When I ran into a similar problem, the method @Benedict mentions was never triggered for me. This is because NSOutlineView has a separate method:
- (void) outlineView:(NSOutlineView*)aTableView
willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn*)aTableColumn
item:(id)item;
See the documentation for the NSOutlineViewDelegate protocol. (This formal protocol is new in 10.6 — in previous versions of OS X, the methods were implemented as a category on NSObject.)
Quinn Taylor
2009-09-18 05:08:45