Re: drag & drop objects
Re: drag & drop objects
- Subject: Re: drag & drop objects
- From: Joe Wildish <email@hidden>
- Date: Tue, 3 Jul 2007 15:48:13 +0100
On 3 Jul 2007, at 15:16, Ken Tozier wrote:
Hi Ken,
If I'm doing drag-and-drop within the same application, I often
have some kind of instance variable somewhere that stores
reference to the item being dragged. Once the drag is complete, I
have the method query the instance variable, rather than the
pasteboard. That way I can avoid the pasteboard all together.
How do you avoid the pasteboard? The
"dragImage:at:offset:event:pasteboard:source:slideBack:" method
requires a pasteboard. Do you just create a dummy one and ignore
it? I would think that, at the very least, the drag target would
need to know what type of data is being dropped so it highlights
correctly and can decide to handle the drop or not...
I usually create a dummy pasteboard I think (it's been a while). You
may be able to have nil as the pasteboard, if you've registered for
all pasteboard types, but I've never tried it. Someone feel free to
correct me.
As I say, if you are dragging within the same application, you have
all the knowledge you need, regardless of what is on the pasteboard.
Say you are dragging within the same view - once the drag starts, you
can set an ivar to equal the data being dragged. If focus moves to
place within the view where it might be appropriate to drop, the code
can query that ivar to see if it's OK to receive it (and draw a focus
ring, or whatever). The drag action can just act as a trigger for the
code to query the ivar basically. You can largely ignore the drag
destination protocol implementation.
HTH,
-Joe
_______________________________________________
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