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 (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 [EMAIL PROTECTED]

Reply via email to