Hello,
I would like to ask how to clearly implement custom drag and drop logic via SmartGWT. What I need to do is to move one Window (placed in Layout) over the other securing those two windows will swap. I thought i can secure this by setting canDropComponents(false) and canAcceptDrop(true) as written in the documentation.
The thing is that I still recieve DropOut and DropOver events but NOT DropOn event.
the code for swap
Thanks a lot
I would like to ask how to clearly implement custom drag and drop logic via SmartGWT. What I need to do is to move one Window (placed in Layout) over the other securing those two windows will swap. I thought i can secure this by setting canDropComponents(false) and canAcceptDrop(true) as written in the documentation.
The thing is that I still recieve DropOut and DropOver events but NOT DropOn event.
the code for swap
Code:
public static void swapWidgets(PerspectiveWidget w1, PerspectiveWidget w2) { Layout w1l = w1.getEnclosingLayout(); Layout w2l = w2.getEnclosingLayout(); w1l.removeMember(w1); w2l.removeMember(w2); w1l.addMember(w2); w2l.addMember(w1); }
Code:
setCanDropComponents(false); setCanAcceptDrop(true); setCanDrop(true); setCanDragReposition(true); setCanDrag(true); addDropHandler(new DropHandler() { @Override public void onDrop(DropEvent event) { com.google.gwt.user.client.Window.alert("drop!"); // window.alert does even not trigger Canvas droppedCanvas = EventHandler.getDragTarget(); if (droppedCanvas instanceof PerspectiveWidget) { PerspectiveWidget pw = (PerspectiveWidget) droppedCanvas; PerspectiveManager.swapWidgets(PerspectiveWidget.this, pw); } } }); addDropOverHandler(new DropOverHandler() { @Override public void onDropOver(DropOverEvent event) { enclosingLayout.setBackgroundColor("#FFFF88"); //this works } });
Comment