Re: Rearranging NSOutlineView via drag-and-drop
Re: Rearranging NSOutlineView via drag-and-drop
- Subject: Re: Rearranging NSOutlineView via drag-and-drop
- From: Charles Jenkins <email@hidden>
- Date: Sun, 04 Jan 2015 08:22:43 -0500
Quincy:
Thanks for the answer! But something is still missing...
moveItemAtIndex:… does indeed move the items around to the proper places in the tree, but the outline view control doesn’t update disclosure triangles. Meaning, if I drag an item’s only child someplace else, the now-childless parent keeps its useless disclosure triangle. Worse, if I drop a new child onto an item that formerly did not have children, the needed disclosure triangle doesn’t appear, and then there’s no way in that session to manipulate the child item again.
Is there a way to indicate that disclosure triangles and item icons should be updated after the move animation ends?
—
Charles Jenkins
On Saturday, January 3, 2015 at 3:33 PM, Quincey Morris wrote:
> On Jan 3, 2015, at 12:13 , Charles Jenkins <email@hidden (mailto:email@hidden)> wrote:
> >
> > These things work, and I can verify that the object graph in the model has changed correctly. But to see the changes reflected in my Source View, I have to collapse and re-expand the affected nodes in order to have them reload data from the model in its new state. (I’m kind of surprised that updating the outline isn’t automatically done as a result of successfully accepting an NSDragOperationMove.)
>
> The outline view doesn’t know the semantics of the move. All you’ve done, at the validation stage, is decide what kind of *feedback* to give to the user.
> > Is it a good idea to call reload functions from outlineView:acceptDrop:item:childIndex:, or should I be doing something else to update the outline?
>
> Something else. There are these methods that you use (in acceptDrop) to tell the outline view the semantics of what the drop did:
>
> moveItemAtIndex:…
> insertItemsAtIndexes:…
> removeItemsAtIndexes:…
>
> By using combinations of these, you can avoid a reload. (Reloads essentially throw away information and re-acquire it. These methods describe the changes without loss of current state information.)
>
> The effects of these methods are batched and deferred to a later iteration of the run loop, and they also have the benefit of allowing the outline view to animate the changes nicely, which a reload can’t do.
>
_______________________________________________
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