Drag and drop within application

I’m trying to do drag & drop within my application, between container controls and/or canvases.
I decided to pass text which ultimately will represent an object that can be created in the receiver.
On the source container control, I have code like this:

Dim di As DragItem

di = New DragItem(Me,X,Y,100,60)
di.Drag
di.text = “some text”

on the receiver I have something like this

Me.AcceptTextDrop // this is in the Constructor

And a DropObject event containing:

MsgBox “DROPPED!”

I can drag from the source, there is a box that moves around with the mouse cursor. It isn’t centered on the mouse cursor, which is annoying.

When I drop, nothing happens.

Am I doing something wrong, or is this just not possible?

TIA

Are-you able to do that with your platform provided applications ?

Nota: when I do what you asked with the text selected above and tried to drag it, the text is not centered below the mouse (Firefox). But, if I click and drag at the center of the selected text, I can watch what you are asking.

Edit:
Never use a MsgBox to debug purposes. Use instead System.DebugLog (“text”)

Me, needs to investigate further into this hint.

New in REALbasic 5.5.

Description: http://documentation.xojo.com/api/os/system.html#system-debuglog

Hi Emile
Thanks for your reply. Yes System.DebugLog…I actually know about that but the MsgBox is a habit I need to get over!

I’m on OSX, and if I drag over the desktop, the box is there (so it seems to be working in that regard). I tried dropping on the desktop, nothing happens. I tried dropping into TextEdit.app…nothing happens. The box flies back to where it was dragged from.

I sorted it out
The reason it doesn’t work, is that di.Drag must be last. The .text property needs to be set, or whatever data is to be dragged needs to be set, before calling .Drag

Also BTW drop seems to work with an object subclassed from a ContainerControl, but not one subclassed from a Canvas.