Re: Rearranging NSOutlineView via drag-and-drop
Re: Rearranging NSOutlineView via drag-and-drop
- Subject: Re: Rearranging NSOutlineView via drag-and-drop
- From: Quincey Morris <email@hidden>
- Date: Sat, 03 Jan 2015 20:33:02 +0000
On Jan 3, 2015, at 12:13 , Charles Jenkins <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