Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Drag-and-Drop Layout

    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
    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            }
            });
    Thanks a lot
    Last edited by d1x; 2 Feb 2011, 05:56.

    #2
    Up! Here is a similar thread http://forums.smartclient.com/showthread.php?t=7782. Does anyone know the solution?:)
    Last edited by sbartosz; 5 Aug 2011, 02:07.

    Comment

    Working...
    X