Hi,

Although there is a fair number of posts referencing "expandItem" I couldn't quite find this in the archives, although I had expected it to be a fairly common scenario:

I search for an item that belongs to a tree that is shown in an NSOutlineView. When I find the item, I want the outline view to show the it (if it is currently collapsed) and select its row. For that I wrote the following code, that should ensure the selected item's ancestry is expanded, and then selects the targeted item:

                while (currentOutline.parent != nil) {
                currentOutline = currentOutline.parent;
                [clerkDocument.outlinesOutlineView expandItem:currentOutline];
        }
                
[clerkDocument.outlinesOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[clerkDocument.outlinesOutlineView rowForItem:match]] byExtendingSelection:NO];

Running this through the debugger I checked that each ancestor of the item gets expanded, and the code executes correctly. However, if several of the ancestors were collapsed, then after this code above is executed the outline only ends up expanding the top previously expanded ancestor, and the targeted item doesn't get selected (because there is no row for item "match" since it is not visible). All the ancestors have been set to expand though.

Is there anything wrong with my understanding of how NSOutlineView operates in this respect, or could this be a bug in NSOutlineView, and if so, is there a workaround?

António

--------------------------------------------------------
Today you are You, that is truer than true.
There is no one alive who is Youer than You.
Today I am Me, and I am freer than free.
There is no one alive who is Me-er than Me.
I am the BEST I can possibly be.

--Dr. Seuss
--------------------------------------------------------


_______________________________________________

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