Re: NSOutlineView force expansion/refresh?
Re: NSOutlineView force expansion/refresh?
- Subject: Re: NSOutlineView force expansion/refresh?
- From: Markus Spoettl <email@hidden>
- Date: Wed, 16 Jul 2008 19:29:57 -0700
On Jul 16, 2008, at 3:22 PM, Michael Hanna wrote:
I'm using observeValueForKeyPath:ofObject:change:context: to detect
when a change occurs in my data model. When a non-leaf node gets
added, the outline view draws the new item, but in an unexpanded
state. I try this code:
[m_rulesOutlineView noteNumberOfRowsChanged];
// expand all items in outline view
int c;
for (c = 0; c < [m_rulesOutlineView numberOfRows]; c++)
{
id item = [m_rulesOutlineView itemAtRow:c];
[m_rulesOutlineView expandItem:item];
[m_rulesOutlineView
setNeedsDisplayInRect:[m_rulesOutlineView rectOfRow:c]];
}
in order to expand the new item. The new item expands(i.e. the
triangle points downward) but the leaf nodes aren't actually drawn.
The user has to undisclose, then disclose the new triangle in order to
see the children.
I don't know if that causes your problem but you should know that -
numberOfRows: grows as you expand items. The most simple way to get
around implications that are caused by this behaviour this is going
through the items in reverse order like this:
for (c = [m_rulesOutlineView numberOfRows] - 1; c >= ; c--)
{
// expand items here
}
That way you will avoid looking at rows that have been created as a
result of expanding an item.
Also, I don't think that you have to call -setNeedsDisplayInRect: on
the items, that's something NSOutlineView should be managing.
Markus
--
__________________________________________
Markus Spoettl
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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