• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Putting object references into Pasteboard for Drag And Drop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Putting object references into Pasteboard for Drag And Drop


  • Subject: Re: Putting object references into Pasteboard for Drag And Drop
  • From: Nelson Santos <email@hidden>
  • Date: Fri, 2 Jun 2006 21:51:17 -0700

Hi Michael,

Thanks buddy! It worked like a charm. And it's so simple! Dagnabbit. I wish I was able to think of it on my own. But I guess that's the purpose of this list.

Thanks again!

Regards,
Nelson



On Jun 1, 2006, at 12:09 PM, Michael Ash wrote:

On 6/1/06, Nelson Santos <email@hidden> wrote:
Hi all,

I have two table views in my app for which I have successfully
implemented drag and drop using the standard documented methods.

i.e.:
A) I have defined a custom Pboard type,
B) I have implemented the required methods such as acceptDrop and
writeRows (and the other necessary methods)
C) I am using method archiveDataWithRootObject to store my object in
the pasteboard to be unarchived at the receiving end.

It works great.

Now I realize that I don't want to archive and unarchive the data
because this creates a new copy of the object.  I need to original
object (it's reference) to be received at the dropped end.  I don't
know how to do this.
[snip]

This is very easy to do, although not at all obvious.

In your -performDragOperation:, you get an NSDraggingInfo. You can ask
that for its source by doing [sender source]. The source is the object
that initiated the drag, either your view or its controller, depending
on how you set things up. So all you have to do is have a custom
method which returns the drag object, and then ask the source for it
in your destination. You bypass the question of pasteboards
altogether, skip the ugly bits where you stuff pointers into places
they shouldn't go, and get the object directly. You may have to
subclass NSTableView to add the right method but it should all be
straightforward.

Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Putting object references into Pasteboard for Drag And Drop (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: NSTextView Drag and Drop (Colors)
  • Next by Date: NSControl and NSCell
  • Previous by thread: Re: Putting object references into Pasteboard for Drag And Drop
  • Next by thread: ANN: CamelBones 1.0.0rc1
  • Index(es):
    • Date
    • Thread