fredsa / gwt-dnd

Library providing easy to use mouse or touch based drag-and-drop capabilities to GWT
43 stars 41 forks source link

PopupPanel CloseHandler removed when dragging #87

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of GWT are you using? 1.3.3? 1.4.60? Other?

gwt 1.7

What version of the gwt-dnd jar file or library file are you using?

2.6.5

What operating system(s) are you using? Windows? Linux? Mac?

Windows

Does the issue occur in web mode, hosted mode, both or don't know?

both

What browser(s) do you use? Firefox, IE, Safari, other?

Firefox and IE

What is the browser version (if you know) from Help->About?

Firefox 3.5, IE8

What steps will reproduce the problem? Please attach sample code if you
can.

public void onModuleLoad() {
        RootPanel rootPanel = RootPanel.get();

        PickupDragController defaultRootPanelDragController =  new
PickupDragController(rootPanel, false);
        defaultRootPanelDragController.setBehaviorConstrainedToBoundaryPanel(false);
        defaultRootPanelDragController.setBehaviorDragProxy(false);
        DropController dropControllerDefaultRootPanel = new
AbsolutePositionDropController(RootPanel.get());

defaultRootPanelDragController.registerDropController(dropControllerDefaultRootP
anel);

        final PopupPanel popUpPanel = new PopupPanel();
        VerticalPanel vpanel = new VerticalPanel();
        Button closeButton = new Button("x");
        closeButton.addClickHandler(new ClickHandler(){
            @Override
            public void onClick(ClickEvent event) {
                // TODO Auto-generated method stub
                System.out.println("close btn clicked");
                popUpPanel.hide();
            }
        });

        Label dragHandle = new Label("the drag handle");
        vpanel.add(dragHandle);
        vpanel.add(new Label("Test"));
        vpanel.add(closeButton);

        popUpPanel.setWidget(vpanel);
        popUpPanel.addCloseHandler(new CloseHandler<PopupPanel>(){
            @Override
            public void onClose(CloseEvent<PopupPanel> event) {
                // TODO Auto-generated method stub
                System.out.println("CloseHandler close called ");

            }
        });

        defaultRootPanelDragController.makeDraggable(popUpPanel,dragHandle);
        popUpPanel.center();

    }

What is the expected output? What do you see instead?

expected:
"close btn clicked"
"CloseHandler close called"

I see:
"close btn clicked"

Do you have a workaround?

no

Please provide any additional information below.

It seems that the CloseHandler of the PopupPanel is removed when the
PopupPanel was dragged.
This Problem arised when we updated to gwt 1.7 and gwt-dnd 2.6.5. With gwt
1.5 and the old gwt-dnd lib it worked fine.

Original issue reported on code.google.com by bertknec...@web.de on 2 Sep 2009 at 2:01

GoogleCodeExporter commented 9 years ago
Copying comment from issue 43 (Dragging removes PopupPanel's EventPreview from 
the 
DOM):

Unfortunately, the way PopupPanel and gwt-dnd are designed, the two are largely 
incompatible. gwt-dnd must detach and reattached widgets in order to drag them 
correctly while PopupPanel is designed to be in control of it's "attachedness". 
It 
also as a fail safe in the form of an onUnload() method which disconnects the 
event 
preview if the widget is detached (as it is when gwt-dnd starts dragging it).

Instead of using PopupPanel, try one of these options:

1. Use DialogBox which can already be dragged by its heading without the need 
for 
gwt-dnd enabled dragging

2. Create your own panel (perhaps using DecoratorPanel) which can be dragged 
with 
gwt-dnd. Borrow some of the code from PopupPanel if you need to, but don't 
include 
the event preview code.

Marking as 'WontFix'.

Original comment by fredsa on 19 Oct 2009 at 6:07