[fxruby-users] new DND idea

Lyle Johnson lyle.johnson at gmail.com
Mon Mar 19 10:52:41 EDT 2007

On 3/19/07, Raj Sahae <rajsahae at gmail.com> wrote:

> Hi there.  Some of you may remember that I was having problems with
> DND.  I solved that problem using YAML.  However, I have run into new
> problems because YAML creates a new instance of the object, exactly
> equal to the old one, but nonetheless, a new object in a different
> memory location.

Right, and this is a good thing if you're dragging the object to
another instance of the application that doesn't share the same memory

> Instead of doing that, I wish to simply pass the
> actual reference, the memory location, of the object.  How would I do
> that?  For example, if "card" in this case was a reference to on object
> at 0x0000001 (contrived, yes):


> Instead of encoding the YAML.dump, I would encode what?  And on the
> otherside, I would decode and then what?

It sounds like you're assuming that it's always going to be a "local"
drag and drop (i.e an object is dragged and dropped within the same
application instance). In that case, the simplest solution might be to
just use the object's id as its encoding:

    setDNDData(FROM_DRAGNDROP, @image_drag_type, card.__id__.to_s)

and then decode it using ObjectSpace#_id2ref:

    data = getDNDData(FROM_DRAGNDROP, @image_drag_type)
    card = ObjectSpace._id2ref(data.to_i)

Hope this helps,


More information about the fxruby-users mailing list