Re: NSOutlineView doesn't call outlineView:shouldSelectItem: after selectRowIndexes:byExtendingSelection:
Re: NSOutlineView doesn't call outlineView:shouldSelectItem: after selectRowIndexes:byExtendingSelection:
- Subject: Re: NSOutlineView doesn't call outlineView:shouldSelectItem: after selectRowIndexes:byExtendingSelection:
- From: Kyle Sluder <email@hidden>
- Date: Mon, 14 Nov 2011 19:24:08 -0800
On Mon, Nov 14, 2011 at 6:18 AM, Motti Shneor <email@hidden> wrote:
> However, if we need to PROGRAMMATICALLY set the selection, using selectRowIndexes:byExtendingSelection: for example, outlineView:shouldSelectItem: is never called.
>From "Selecting and Deselecting Rows Programmatically" in the Table
View Programming Guide:
> Note: It is important to note that when the row is changed programmatically the selectionShouldChangeInTableView: message is not sent to the delegate. This means that the application is responsible for ensuring the validity of the contents of the currently selected row if it is being edited.
http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TableView/RowSelection/RowSelection.html#//apple_ref/doc/uid/10000026i-CH6-SW6
The point is that you can make programmatic changes that the user
can't make with the mouse. The most common case is to disallow the
user from making any selection changes at all; only the program can
change the selection.
Just reuse whatever logic you've put into
-outlineView:shouldSelectItem:. If you want, factor out the validation
logic into its own method. If the conditions aren't met, either pass a
different set of row indexes to
-selectRowIndexes:byExtendingSelection: or just don't call that method
at all.
--Kyle Sluder
_______________________________________________
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