PDA

View Full Version : Drag/Drop to same control



neilgfoster
January 17th, 2011, 13:12
Hi,

I am writing a custom control which includes a token that can be dragged around the control. However, what I am observing is that the onDrop event does not fire when I release the token over the same control that the drag started on.

Everything works fine when I drag from one control to another - the onDrop event fires fine, just not when dropping on the same control.

Anyone else observed this behaviour, or know if this is the correct behaviour for drag/drop operations?

Thanks

Sorcerer
January 17th, 2011, 13:22
I have not personally tried to do this, but the FG2 reference files for onDrop give the following warning...

"The token interface for drop events is different than other objects in that a handler must be registered to intercept drop events"

drahkar
January 17th, 2011, 15:08
I suspect the problem you are having is that the drag process is initiated by dragging off of the control. What you might try doing is dragging it completely off the control and then back. That -might- work. But in reality I'm not sure you can drag then drop onto the same control.

neilgfoster
January 17th, 2011, 15:17
The drag process starts as soon as the mouse is moved with the button held down, it doesn't need to move off the control for the operation to start. However, it does look like a drop event is only fired when the dragdata is dropped onto a different control.

I have managed to work around this - the onDragEnd event is fired for the control, so I check the mouse's x,y position relative to the control and window to determine where the token was moved too. It works fine, just took a fraction more code than expected.

drahkar
January 17th, 2011, 15:19
That was basically my concern as I didn't think it was fired when going to the same control. That is fantastic and a very ingenious solution to the problem however.