Search code examples
objective-cmacoscocoansbrowser

How to highlight a row in NSBrowser?


I tried to highlight the rows in a NSBrowser using selectRowIndexes of the NSBrowser,but it does not highlight the rows.In 'NSTableView`rows can be highlighted using

 - [NSTableView selectRowIndexes:byExendingSelection:]

  - (void)selectRowIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger).

Is there any api to highlight the rows in NSBrowser? I would like to highlight the rows without a mouseclick on the browser,I have some known indexes I want to highlight these rows in my custom method.


Solution

  • To select the first five rows in the first column :

    NSIndexSet *indexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,4)];
    [myNSBrowser selectRowIndexes:indexes inColumn:0];
    

    To select the fourth row in the first column :

    [myNSBrowser selectRow:3 inColumn:0];