I'm using NSOutlineView for a project, and can't seem to figure out two things:
Is there some sort of NSOutlineView Delegate method that is used for this? Or does it require a subclass?
You've run into the right person here. I've had to grapple with this just a week ago.
Removing the disclosure triangle: implement the frameOfOutlineCellAtRow:
method in your NSOutlineView
subclass and return NSZeroRect
(only if you want to hide that particular row's triangle, of course.)
- (NSRect)frameOfOutlineCellAtRow:(NSInteger)row {
return NSZeroRect;
}
Disable indenting: the outline view's standard layout reserves space at the far left to draw the triangles in, in case the item is expandable. But you can override that for individual items by specifying a different drawing frame. You also do that in your subclass, by responding to this message:
- (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row {
NSRect superFrame = [super frameOfCellAtColumn:column row:row];
if ((column == 0) /* && isGroupRow */) {
return NSMakeRect(0, superFrame.origin.y, [self bounds].size.width, superFrame.size.height);
}
return superFrame;
}