Re: OutlineEdit example (_NSArrayControllerTreeNode)
Re: OutlineEdit example (_NSArrayControllerTreeNode)
- Subject: Re: OutlineEdit example (_NSArrayControllerTreeNode)
- From: Keith Blount <email@hidden>
- Date: Tue, 3 May 2005 08:59:32 -0700 (PDT)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Many thanks for your reply. Using your suggestion, I
tried using the private method observedObject, and
this worked perfectly (well, apart from the compiler
warnings, as you said). Thus, the following
implementation of the delegate method creates variable
row heights in the OutlineEdit example based on the
text entered (though obviously it doesn't alter the
field editor height during editing, which is a whole
other complicated issue):
- (float)outlineView:(NSOutlineView *)anOutlineView
heightOfRowByItem:(id)item
{
NSTableColumn *tabCol = [[outlineView tableColumns]
objectAtIndex:0];
float width = [tabCol width];
NSRect r = NSMakeRect(0,0,width,1000.0);
NSCell *cell = [tabCol dataCellForRow:[outlineView
rowForItem:item]];
//NSString *test = [[[outlineTreeController content]
objectAtIndex:[outlineView rowForItem:item]]
valueForKey:@"contents"];
NSString *test = [[item observedObject]
valueForKey:@"contents"];
[cell setObjectValue:test];
float height = [cell cellSizeForBounds:r].height;
if (height <= 0) height = 16.0;
return height;
}
I'm not entirely happy being forced into using a
private method, though - it's like you say, the
_NSArrayControllerTreeNode proxy object passed in as
"item" to NSOutlineView's delegate methods does indeed
seem like a "brick" - there's just nothing you can do
with it, and no other easy way of accessing the cell
values. I wonder what is the point of having a private
proxy object passed to the delegate methods? Maybe
it's just that NSTreeController isn't entirely
complete yet? It certainly seems not to be a full
solution to outline view data. Annoying, anyway.
Thanks for the tip about drag and drop - I will want
to implement this. The fact that I will have to
implement a couple of hacks to get NSTreeController
working properly for varying row heights and drag and
drop makes me seriously consider not using it - maybe
I should just stick to my old hierarchical custom
model objects (though they're a pain too)...
Yep, definitely annoying.
Thanks again for the reply and help,
Keith
>
> FROM : Scott Stevenson
> DATE : Tue May 03 02:27:31 2005
>
> On May 2, 2005, at 3:32 PM, Keith Blount wrote:
>
> > This is driving me nuts now... There must be an
> easy
> > way to get the value of an object stored at a
> > particular row and column within an outline view
> that
> > uses NSTreeController and bindings, and I must be
> > missing the obvious...
>
>
> I ran into something similar to this, but with a
> different delegate
> method.
>
> It does seem that the "item" object is rather
> difficult to work with
> when the outline view is bound to a Tree Controller.
> I
> thought KVC
> messages would to do the proper thing, but the proxy
> doesn't seem to
> like that.
>
> After trying a number of other things, I resorted to
> just calling -
> observedObject on the item to get to the thing it
> points at. This
> will generate a compiler warning because it's
> private
> API (so it
> could break at any time), but there just doesn't
> seem
> to be any other
> solution. That proxy object is like a brick.
>
> Also, to save you some time in the future -- you
> might
> find that you
> have to implement dummy/empty data source methods to
> get drag and
> drop to work with NSTreeController.
>
>
> - Scott
>
> -----
>
> FROM : Keith Blount
> DATE : Tue May 03 00:32:43 2005
>
> Having played around some more, the problem I seem
> to
> be having with this is that the item passed into the
> outlineView:heightOfRowByItem: delegate method is of
> a
> private _NSArrayControllerTreeNode class, which
> means
> I can do nothing with it. I therefore need to get
> the
> value in the cell at this position, but that is more
> difficult than it seems. I thought I would be able
> to
> do it like this:
>
> NSString *contents = [[[outlineTreeController
> arrangedObjects] objectAtIndex:[outlineView
> rowForItem:item]] valueForKey:@"contents"];
>
> However, it seems that NSTreeController's
> arrangedObjects does not return a simple NSArray -
> instead, it returns a private class called
> _NSControllerTreeProxy - which doesn't respond to
> objectAtIndex:...
>
> This is driving me nuts now... There must be an easy
> way to get the value of an object stored at a
> particular row and column within an outline view
> that
> uses NSTreeController and bindings, and I must be
> missing the obvious...
>
> If anyone could point me in the right direction, I
> would be very grateful.
>
> Thanks again,
> Keith
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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