Re: Getting an NSOutlineView Item's parent
Re: Getting an NSOutlineView Item's parent
- Subject: Re: Getting an NSOutlineView Item's parent
- From: Perrog <email@hidden>
- Date: Wed, 18 Oct 2006 19:11:43 +0200
You normally retrieve the parent item from your own data model. The
"item" input to objectValueForTableColumn isn't retained by
NSOutlineView so it might be invalid if you don't manage it yourself.
I think you are "abusing and not using" the NSOutlineView.
However, to compute the parent item, you can start at the row previous
to the item, and decrement the row count, checking if the previous
item is expandable and if it is expanded. If that is the case, then it
is the parent. (This idea comes from my way of saving the ouline view
state and not actually used to retrieve the parent item.)
for( int row = [outlineView rowForItem:theItem] - 1; row >= 0; --row ) {
id item = [outlineView itemAtRow:idx];
if( item == nil ) {
return gRootItem; // the root parent
}
if( [outlineView isExpandable:item] == YES && [outlineView
isItemExpanded:item] == YES) {
// item is the parent for theItem
} else {
// item is sibling for theItem
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden