Drag And Drop From outside an AbsoluteLayout

Hello there

I’m working on a problem for a while which I couldn’t solve yet. I want to drag a button / icon from outside an AbsoluteLayout and drop it into this layout.

Most of the functionality is working so far. I’ve put the button in an DragAndDropWrapper and I’m able to drop it inside the absoluteLayout. My only problem at the moment is the positioning when dropping the button inside the absoluteLayout for the first time / from outside into the layout.

Normally you handle the drag-and-dropping by adding a “move-vector” (mouse.release - mouse.click) to the original position of the component you want to drag. But when you get a component from outside the absoluteLayout that’s not possible.
I need a way to a) determine the absolute position of the absoluteLayout on the screen to be able to calculate between the absolute screen-position and the relative position inside the absoluteLayout or b) I must somehow get the relative position of a drop inside the absoluteLayout.

After some dead ends I tried using the mouseEvent.getRelativeX/Y()-function but this method always returned -1. Seems that there never has been a related Element (?)

After that I’ve tried to add a LayoutClickListener to the absoluteLayout but when dropping an item that doesn’t count as a click. When performing a “normal” click this works fine (here the mentioned getRelativeX() method produces the wanted results).

I’ve read about extending the ClickEventHandler or using GWT to somehow extract the position of the absoluteLayout. Am I outing myself as a newbe when I’m saying that I don’t know how to do that? Is my class (lets name it dragAndDropScreen) supposed to extend the ClickEventHandler or do I need to add the handler to some listener which again needs to be added to my layout or mit DragAndDropWrapper? I’m lost.

I’m glad about any help. Maybe you also have a different idea? I hope I could explain the problem.

Greetings
Michael