Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you get indexes of visible rows for an NSOutlineView?

How can you get a indexes of visible rows for an NSOutlineView? I need to know which level and which rows are visible.

[EDIT] What I'm actually looking for is an NSOutlineView equivalent to CocoaTouch/UITableView - (NSArray *)indexPathsForVisibleRows

like image 856
Cal Avatar asked Jan 19 '11 01:01

Cal


2 Answers

you can do the following:

NSScrollView* scrollView = [self.tableView enclosingScrollView];

CGRect visibleRect = scrollView.contentView.visibleRect;

NSRange range = [self.tableView rowsInRect:visibleRect];

in the range you will get the location as the first visible cell and in the length the amount of cells are shown so you can know the index of the visible cells.

like image 183
user2067656 Avatar answered Oct 13 '22 18:10

user2067656


NSOutlineView is an NSTableView subclass. Therefore -rowsInRect: can be combined with -visibleRect (from NSView). Use -levelForRow: to determine the level.

like image 25
Joshua Nozzi Avatar answered Oct 13 '22 18:10

Joshua Nozzi