objective-ccocoansoutlineviewoutline-view

Changing the position of NSOutlineView disclosure triangle and setting up icons for child nodes


I am creating an OutlineView like this:

My OutlineView

And I want to achieve a view which looks like this:

Desired view

The 2 issues that I am facing are:

  1. I cant find a way to move the disclosure triangle between the folder icon and the name.

  2. I am unable to setup the "P" icon for the child nodes.

For the 2nd issue, this is the code I tried setting up the icon with:

- (void)outlineView:(NSOutlineView *)aTableView willDisplayCell:(NSCell*)aCell forTableColumn:(NSTableColumn *)aTableColumn item:(id)item
{
    NSImage* image = nil;
    BOOL isLeaf = [item isLeaf];
    
    if ([[aTableColumn identifier] isEqualToString:@"styleIcon"]) {
        
        if (aTableView == _charOutlineView) {
             image = [QXPGeneralInterfaces imageFor:(isLeaf ? kCharacterIconImage : kFolderIconImage)];
        }
        else {
            image = [QXPGeneralInterfaces imageFor:(isLeaf ? kParagraphIconImage : kFolderIconImage)];
        }
        
        if (image != nil) {
            [aCell setImage:image];
        }
}

aCell does set the image but somehow it disappears in the UI.


Solution

  • I cant find a way to move the disclosure triangle between the folder icon and the name.

    Put the folder icon in column 0 and the title in column 1. Set outlineTableColumn (or the Outline Column in IB) to column 1.