Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: OutlineEdit example (outlineView:heightOfRowByItem:)



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

---- ORIGINAL MESSAGE ----

Hmm, still struggling with this...

In theory, you should be able to use the new variable
height delegate methods of NSOutlineView and
NSTableView to support arbitrary heights depending on
content, but I am getting some very odd drawing errors
when doing this in an editable outline view. I am
trying to add the outlineView:heightOfRowByItem:
delegate method to the new (Core Data) OutlineEdit
example, but the drawing and selection is going mad. I
have set MyDocument as the delegate and added these
delegate methods:

- (float)outlineView:(NSOutlineView *)outlineView
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]];
   float height = [cell cellSizeForBounds:r].height;
   if (height <= 0) height = 16.0;
   return height;
}

- (void)outlineView:(NSOutlineView *)outlineView
willDisplayCell:(id)cell forTableColumn:(NSTableColumn
*)tableColumn item:(id)item
{
   [cell setWraps:YES];
}

Does anybody know how to do this, or why these methods
would be causing such weird drawing errors?

Many thanks in advance,
Keith

__________________________________________________
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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.