I'm trying to implement an drag & drop in my project. I already managed, but now i want to distinguish the drag source.
I will have two widget from were i can drag lets call widget1 and widget2:
widget1.getElement().setDraggable(Element.DRAGGABLE_TRUE);
widget2.getElement().setDraggable(Element.DRAGGABLE_TRUE);
i made the handler for each one
widget1.addDragStartHandler(new DragStartHandler() {
@Override
public void onDragStart(DragStartEvent event) {
// TODO Auto-generated method stub
event.setData("text", "i am widget1");
});
widget2.addDragStartHandler(new DragStartHandler() {
@Override
public void onDragStart(DragStartEvent event) {
// TODO Auto-generated method stub
event.setData("text", "the text is different i am widget2");
now i had two absolute panels one only can receive from widget 1 and the other from widget 2
pNorth.addDomHandler(new DropHandler() {
@Override
public void onDrop(DropEvent event) {
if(widget1){
// Prevent the native text drop.
event.preventDefault();
// Get the data out of the event.
String text= event.getData("text");
pNorth.getElement().getStyle().setBackgroundImage("url("+text+")");
}}
}, DropEvent.getType());
how can i manage to do that?
thanks for the help.