Re: NSOutlineView and selection
Re: NSOutlineView and selection
- Subject: Re: NSOutlineView and selection
- From: Corbin Dunn <email@hidden>
- Date: Wed, 12 Jan 2011 10:59:10 -0800
On Jan 12, 2011, at 10:45 AM, Kevin Meaney wrote:
> Hi,
>
> In my outline view I need to allow multiple selection, but only allow all selected items to have the same parent. In other words as soon as the user selects an item with a different parent to the currently selected items even if they are in add to selection mode, the previously selected items get deselected.
>
> The NSOutlineView documentation does not seem to be complete on the relevant methods. According to the NSTableView documentation if the delegate method: tableView:selectionIndexesForProposedSelection is implemented then selectRow:byExtendingSelection will not be called and the documentation for both is available. But for NSOutlineView there doesn't appear any documentation for the delegate method outlineView:shouldSelectItem and the information in the header file only says that for performance reasons it is better to use outlineView:selectionIndexesForProposedSelection:
>
> But there is not enough information like for the table view documentation as to whether either of methods are mutually exclusive or not,
Hi Kevin,
The header says:
/* Optional - Return a set of new indexes to select when the user changes the selection with the keyboard or mouse. If implemented, this method will be called instead of outlineView:shouldSelectItem:. This method may be called multiple times with one new index added to the existing selection to find out if a particular index can be selected when the user is extending the selection with the keyboard or mouse. Note that 'proposedSelectionIndexes' will contain the entire newly suggested selection, and you can return the exsiting selection to avoid changing the selection.
*/
- (NSIndexSet *)outlineView:(NSOutlineView *)outlineView selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes
In particular:
"If implemented, this method will be called instead of outlineView:shouldSelectItem:. "
Thus, they are mutually exclusive. If there is any way we can make it clearer, please let me know.
You want to use that delegate method to control selection. You can use itemAtRow to find the items and restrict them as you require.
corbin
> but also what are the sequence of events and if it is possible to modify the current selection in these methods and whether these are the right places to make the appropriate changes to achieve the selection behaviour we need.
>
> Thanks
> Kevin
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden