Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide show/hide button in source list ( a view based outline view)

enter image description here

how to hide show /hide button (edited as expand here). even i set it as empty string ,the border for the data cell shrinks as shown in image. previously i used the method - (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item , it hiding the show/hide string and working perfectly. but the problem is the outlineview allows only expanding not collapsing. i want to expand only one parent at a time by clicking the corresponding parent node.

like image 878
user23790 Avatar asked Dec 05 '25 10:12

user23790


2 Answers

Use this method from NSOutlineViewDelegate method :

- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item;
like image 85
Dalzhim Avatar answered Dec 07 '25 20:12

Dalzhim


Finally solved it, this code helped me.

- (NSRect)frameOfOutlineCellAtRow:(NSInteger)rowIndex
{
    NSRect superFrame = [super frameOfOutlineCellAtRow:rowIndex];

    // Return NSZeroRect if the row is a group row
    if ([[self delegate] respondsToSelector:@selector(outlineView:isGroupItem:)]) {
        if ([[self delegate] outlineView:self isGroupItem:[self itemAtRow:rowIndex]]) {
            return NSZeroRect;
        }
    }


    return superFrame;
}
like image 25
user23790 Avatar answered Dec 07 '25 22:12

user23790