Tracking NSBrowser selection

Wednesday, June 15 2011 @ 11:29 AM BST

Contributed by: Admin

Before 10.6, it was not easy to do, subclassing the browser cell was one way to do it, but since 10.6 it's easier, here is how to…

Introduced in 10.6:


- (NSIndexSet *)browser:(NSBrowser *)browser selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes inColumn:(NSInteger)column
By implementing this method in your delegate/datasource, you can test if the selection will be empty after the processing of the proposed index will be done:

BOOL willGoNoSelection = (column == 0) && ([proposedSelectionIndexes count] == 0) ;
and then, according to your needs, turn on/off UI items. The initial state of these items remain to be set up in some "init" method: only you know if the selection is empty at start of the browsing session or not.

0 comments



http://www.macosxguru.net/article.php?story=20110615112914355