NSOutlineView doesn't call outlineView:shouldSelectItem: after selectRowIndexes:byExtendingSelection:
NSOutlineView doesn't call outlineView:shouldSelectItem: after selectRowIndexes:byExtendingSelection:
- Subject: NSOutlineView doesn't call outlineView:shouldSelectItem: after selectRowIndexes:byExtendingSelection:
- From: Motti Shneor <email@hidden>
- Date: Mon, 14 Nov 2011 16:18:11 +0200
Hi Everyone.
Hi everyone. We have a source-detail window, in which the source-view uses an NSOutlineView. We implement it in a rather simplistic way because we only have two levels, one of which is constant (constant sections) and several items in each section. We don't use bindings, or an NSTreeController, but rather implement few delegate and data-source protocol methods. Namely:
- (id)outlineView:child:ofItem:
- (BOOL)outlineView:isItemExpandable:
- (NSInteger)outlineView:numberOfChildrenOfItem:
- (id)outlineView:objectValueForTableColumn:byItem:
- (BOOL)outlineView:isGroupItem:
- (BOOL)outlineView:shouldSelectItem:
Our problem is this:
Whenever a user clicks on an item, outlineView:shouldSelectItem: gets called for the item, and the item can try to show its detail view --- and return YES, or --- if it failed to show its detail, return NO and so prevent the selection.
However, if we need to PROGRAMMATICALLY set the selection, using selectRowIndexes:byExtendingSelection: for example, outlineView:shouldSelectItem: is never called.
We tried to work with the NSOutLineView notifications
- (void)outlineViewSelectionDidChange:(NSNotification *)notification;
- (void)outlineViewSelectionIsChanging:(NSNotification *)notification;
Becasue the header file says:
/* Note for the following NSOutlineViewItem*Notifications:
The 'userInfo' dictionary in the notification will have an @"NSObject" key where the value is the changed (id)item.
*/
but despite this documentation the userInfo dictionary was EMPTY in both notifications, and anyway --- non of them was actually called BEFORE selection was done.
We currently work around this by imitating the whole process (first changing the detail, and only if it succeeds, go on and change the selection in the OutlineView) but this is double implementation, and way too ugly to be a Cocoa program.
Hints anyone?
Motti Shneor,
Senior Software Engineer and Team Leader, Spectrum Reflections LTD.
Office eMail: email@hidden
---
ceterum censeo microsoftiem delendam esse
---
_______________________________________________
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