Re: NSTreeController, NSBrowser image setting
Re: NSTreeController, NSBrowser image setting
- Subject: Re: NSTreeController, NSBrowser image setting
- From: Tony Romano <email@hidden>
- Date: Wed, 24 Mar 2010 15:41:43 -0700
I've determined that what I want to do is not possible with using a NSTreeController and a NSBrowser. As I stated below, the willDisplayCell doesn't have the correct parameters to determine the represented object. Notice the cousin to NSBrowser, NSOutlineView, delegate willDisplayCell has the parameter, (id) item.
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
I've modified my app using the outline view, added the necessary support for the NSOutlineView tableview' cell to support icons and I am able to set images for each item.
I will file a bug. If someone feels different, please let me know.
Thanks,
-tony
On Mar 24, 2010, at 1:58 AM, Tony Romano wrote:
>> From: Tony Romano <email@hidden>
>> Date: March 24, 2010 1:57:04 AM PDT
>> To: Cocoa Developers <email@hidden>
>> Subject: Re: NSTreeController, NSBrowser image setting
>>
>> Thanks Ken, that was somewhat helpful. However, I am still having trouble mapping the arguments passed via(- (void)browser:(NSBrowser *)browser willDisplayCell:(id)cell atRow:(NSInteger)row column:(NSInteger)column; ) and which object it is referring to. With this little snippet I can get to all the children under the root.
>>
>>
>> // treeView is the outlet to the NSTreeController object.
>> NSArray *a = [[treeView arrangedObjects] childNodes];
>>
>> for (NSTreeNode *tn in a)
>> {
>> // node is the object that I provided to the treeController to represent each entry in the tree
>> node *n = [tn representedObject];
>> }
>>
>> The other method supported by the proxy, (NSTreeNode *)descendantNodeAtIndexPath:(NSIndexPath *)indexPath, requires an NSIndexPath object to access any child node in the tree. Building the NSIndexPath seems to be the big blocker. None of the methods for aNSBrowser will let you create an NSIndexPath if the data provided to the browser was not done via a data source. I am assuming I am missing something here.
>>
>> This is how I am assuming it would work
>>
>> NSTreeNode *nodeThatWillBeDisplayed = [treeView NSTreeNode *)descendantNodeAtIndexPath:someIndexPath];
>> node *n = [nodeThatWillBeDisplayed representedObject];
>> // Get the icon for the node
>> // Set the image in the cell passed in via willDisplayCell
>> // Life is good, move on.
>>
>>
>> Anyone that can add some clarity to this, I would be greatly appreciate.
>>
>> -Tony
>>
>>
>> On Mar 23, 2010, at 7:33 PM, Ken Thomases wrote:
>>
>>> On Mar 23, 2010, at 9:22 PM, Tony Romano wrote:
>>>
>>>> I'm using a NSTreeController and bindings to contain the data for a NSBrowser. Data from my objects is being displayed fine. I want to add an image to the entries in the browser. From what I gather, I need to implement the willDisplayCell delegate method. The question I have is how do I get MY object stored for the node being displayed. The documents state you cannot use the itemAt* methods if you did not use a data source, which I didn't. I did find on the Internet someone else who had a similar problem and the solution they found was call this method [item representedObject]. It's not clear what the receiver 'item' is.
>>>
>>> NSTreeController uses its own objects as the items. In Leopard and later, they are NSTreeNode instances. Prior to that, they were completely opaque objects.
>>>
>>> See <http://developer.apple.com/mac/library/releasenotes/Cocoa/AppKitOlderNotes.html#NSTreeController>.
>>>
>>> Regards,
>>> Ken
>>>
>>>
>>
>> -tony
>>
>>
>
> -tony
>
>
> _______________________________________________
>
> 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
>
-tony
_______________________________________________
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