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: Motti Shneor <email@hidden>
- Date: Tue, 15 Nov 2011 12:28:24 +0200
Thanks Kyle. For some reason I missed the superclass (NSTableView) docs when trying to solve my NSOutlineView selection issues.
However --- I remember (our previous implementation) that when you use an NSTreeController (Or NSArrayController in the case of NSTableView) to control the NSOutLineView --- than calling the array controller to select an object --- would definitely cause a "shouldSelect" call on the view delegate.
And there is still the weirdness of the empty userInfo on the Selection related notifications.
On Nov 15, 2011, at 5:24 AM, Kyle Sluder wrote:
> 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