views:

839

answers:

1

The following is when using the drag and drop library from here:

http://code.google.com/p/gwt-dnd/

When placing an absolute panel inside a relative panel, it appears to disable the drag ability. A simple example:

    private AbsolutePanel leftPanelTree = new AbsolutePanel();
    private HorizontalPanel drawingAppPanel = new HorizontalPanel();
    private VerticalPanel leftPanel = new VerticalPanel();
    private VerticalPanel rightPanel = new VerticalPanel();
    private Label rightSideFiller = new Label("Right Side");
    private Label leftSideFiller = new Label("Left Side");
    private Image newImage = new Image("images/link.gif");
    private PickupDragController newDragController = 
        new PickupDragController(leftPanelTree, true);

        public DrawingApplication() {
                initWidget(drawingAppPanel);

                newDragController.makeDraggable(newImage);
                leftPanelTree.setWidth("300px");
                leftPanelTree.setHeight("200px");
                leftPanelTree.addStyleName("panelBorderTest");
                leftPanelTree.add(newImage, 1, 1);

                drawingAppPanel.setWidth("100%");
                drawingAppPanel.setHeight("100%");
                drawingAppPanel.setBorderWidth(2);

                drawingAppPanel.add(leftPanel);
                drawingAppPanel.add(rightPanel);

                leftPanel.setBorderWidth(2);
                leftPanel.setHeight("100%");
                leftPanel.setWidth("100%");
                leftPanel.add(leftSideFiller);
                //leftPanel.add(leftPanelTree);

                rightPanel.add(rightSideFiller);
        }

If, however, I add the image to RootPanel (and change the boundary panel accordingly) or add the absolute panel to the RootPanel directly then drag capability works. Am I missing something here?

+1  A: 

The problem wasn't in my code after all, there is a documented issue with calling RootPanel.get().clear(); which causes this library to basically not function. There is a fix available under this issue here:

http://code.google.com/p/gwt-dnd/issues/detail?id=55

but it was not easy to find. Hopefully this will be patched in a future version if there is one.

Organiccat