Re: NSOutlineView expand by default?
Re: NSOutlineView expand by default?
- Subject: Re: NSOutlineView expand by default?
- From: Dix Lorenz <email@hidden>
- Date: Mon, 19 May 2003 17:10:41 +0200
Hi Chris,
I have an NSOutlineView. I have a desire that I'd like new items to be
automatically expanded in the view if they have not been seen by the
view
before. saveAutoExpandedItems is not a viable solution for me because
the
contents of my NSOutlineView are dynamic.
Some people have suggested simply using 'expandItems' to do this.
However,
that is really not a good solution. First, at the time I am adding
the item
to the NSMutableArray that it belongs to (ie the data source), the
window
may or may not exist. Second, to me it's problematic for my data
source to
know about the outline view that it is assigned to. A single data
source
may be used for multiple outline views and when I add items to the
array I
dont know what those outline views are. (I only find out when the
outlineView calls my data source or delegate methods).
So, I guess I really need something that may not exist... a
"expandItemsByDefault" feature. But seeing as this does not exist, can
anyone recommend an approach to implement this on my own?
I have the same problem (and filed a bug with Apple). I do have a
workaround; it isn't particularly nice or elegant, but it works for me.
If you find a better solution, please let me know...
I have added a Boolean variable to my objects which stores if it had
been expanded or not. Then I have this function:
- (id)outlineView:(NSOutlineView *)outlineView
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
if (item == NULL)
return NULL;
mM5SessionTree_NodeProxy *theNodeProxy = (mM5SessionTree_NodeProxy *)
item;
if ([theNodeProxy wasExpanded] == NO) {
[outlineView performSelector:@selector(expandItem:)
withObject:theNodeProxy afterDelay:0];
[theNodeProxy setWasExpanded:YES];
}
.... regular stuff to get the objectValue
}
Dix
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.