On 09/06/2010, at 2:29 PM, Rua Haszard Morris wrote: > I have an NSOutlineView which has a single column, and 2 levels of tree - > each item in the list can have child items but those subitems don't have > children. > > How can I determine the selected items?
-selectedRowIndexes > > NSTableView -selectedRow returns row indices that change dependent on whether > parent items are expanded, so that won't do. > I could attempt to keep track of the selection via delegate method > outlineView:shouldSelectItem: but this seems a bad idea. > > Am I missing something? Surely it is possible to ask an NSOutlineView which > items are selected? Yes, as above. But bear in mind that the row index has a dynamic relationship with the indexes of items in your data model, because the user can expand and collapse items at will. At the time you call -selectedRowIndexes, you should then extract the items corresponding to those indexes from your data model (e.g. using [NSArray objectsAtIndexes:]) before the user has a chance to change the arrangement. It's also usual to track the selection as it changes in the delegate using the -outlineViewSelectionDidChange: method. You can also get the item associated with a row using [NSOutlineView itemForRow:] --Graham _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com