On Dec 5, 2009, at 12:43 PM, Benjamin Rister wrote: > I have an NSOutlineView in which I would like to have newly-appearing items > be expanded by default. (It would be nice if NSOutlineView had support for > this built in; rdar://problem/7421928.) > > The list archives and a web search reveal a couple hacks to try and make this > work, but they depend on feeding the data to the outline view via the > NSOutlineViewDataSource protocol so that they can ask for an expansion either > at the time of insertion or in response to the outline view asking about the > new pieces of data. I’m using NSTreeController, which makes the situation > difficult as the actual “items” the outline view knows about aren’t anything > I create myself, so I can’t really queue up an expansion of items as I insert > them in the model, nor will the outline view ask me about the new data as > it’s getting it from NSTreeController.
You can get a collection of NSTreeNode instances from your tree controller like this: [[treeController arrangedObjects] childNodes]; Iterate over this collection and find nodes where [node representedObject] is equal to your newly inserted objects. Then you can pass this NSTreeNode instance to -[NSOutlineView exandItem:]. This isn't terribly clean, and it might fall down if you have a large number of items in your tree controller, but it works for what I need and might work for you. Regards, Jason
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com