Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSOutlineView doesn't Collapse Item

I have a NSOutlineView, and clicking on a row will expand/collapse the item if it's expandable.

    if ([self.outlineView isItemExpanded:item]) {
        NSLog("Will collapse item : %@", item);
        [[self.outlineView animator] collapseItem:item];
    }
    else {
        [[self.outlineView animator] expandItem:item];
    }

Expanding the item works as expected, however collapsing the item is not working. I did get the log before executing collapseItem:, and the item is correct. The delegate method - (BOOL)outlineView:(NSOutlineView *)outlineView shouldCollapseItem:(id)item was not called too.

Have been on this problem for hours. Any ideas what causes this?

like image 263
Jensen Avatar asked Jun 19 '13 02:06

Jensen


1 Answers

I figured it out. Seems the item is collapsable only when - (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item returns YES for that item. Otherwise, you can only expand the item.

like image 172
Jensen Avatar answered Oct 08 '22 23:10

Jensen