Determining when dragging begins and ends
Determining when dragging begins and ends
- Subject: Determining when dragging begins and ends
- From: Dave DeLong <email@hidden>
- Date: Fri, 07 May 2010 22:14:32 -0600
Hi everyone,
I've got an outlineView that's displaying some managed objects for me. One of the properties being displayed is a countForFetchRequest: integer. Whenever the outlineView reloads, this count is re-evaluated by querying the managedObjectContext.
I have a problem when I start dragging and dropping to re-arrange these objects. During drag-and-drop, the outline view is constantly invoking reloadData on the outlineView (so that it can redraw the insertion line). The problem with this is that performance degrades visibly, and Instruments reports that during drag-and-drop, over 70% of my execution time is spent performing these count requests.
Due to the nature of these objects, I know that this count cannot change during a drag (although it can change at almost any other time; hence why it is always dynamically calculated). I was thinking that if I could be notified somehow that a drag was beginning, I could tell all my objects to start caching this count, and then return that cached value until I finish dragging.
The problem is that I can't reliably know when dragging ends. I can know when it begins (usually) by detecting the writeItems:toPasteboard: method in my outlineView datasource, but I don't know how to know when it ends; there's no guarantee that my acceptDrop: method will be invoked.
My initial attempts around this have proven unsuccesful. I tried to implement the mouse* events in an outlineView subclass and check the event type to determine when dragging begins and ends (looking for NSLeftMouseDragged, etc), before passing the event on to super. The problem with this is that I'm only seeing the mouseDown: event invoked; never the mouseDragged: or mouseUp: methods. I'm guessing that the NSOutlineView is doing its own event processing loop inside super's mouseDown: so that it can handle dragging itself. If that's the case, this is a dead-end.
So in a nutshell:
How can I reliably know when dragging begins and ends?
Thanks,
Dave
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