fredsa / gwt-dnd

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

Draggable ToggleButton (or CustomButton): uncaught click event. #148

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
> Standards Mode
> GWT 2.4.0
> gwt-dnd 3.1.1
> Windows 7 x64
> Eclipse indigo dev mode (Jetty)
> Firefox 5

I searched amongst issues and googled for this, couldn't find anything. Maybe I 
used the wrong keywords, anyway here is my problem.

After making a ToggleButton draggable, even with BehaviorDragStartSensitivity > 
0, a click event is no longer caught.

See following test code:

//----------------------------------------------------------------

import com.allen_sauer.gwt.dnd.client.DragController;
import com.allen_sauer.gwt.dnd.client.PickupDragController;
import com.allen_sauer.gwt.dnd.client.drop.HorizontalPanelDropController;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RootPanel;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ToggleButton;

public class TestApp implements EntryPoint {

    AbsolutePanel wrapPanel =  new AbsolutePanel();
    PickupDragController dragController = new PickupDragController(wrapPanel, true);

    public void onModuleLoad() {

    RootPanel.get().add(wrapPanel);

    dragController.setBehaviorConstrainedToBoundaryPanel(true);
    dragController.setBehaviorDragStartSensitivity(3);

    HorizontalPanel hPanel = new HorizontalPanel();

    HorizontalPanelDropController dropController = new HorizontalPanelDropController(hPanel);
    dragController.registerDropController(dropController);

    Item b1 = new Item("One", dragController);
    Item b2 = new Item("Two", dragController);

    hPanel.add(b1);
    hPanel.add(b2);

    wrapPanel.add(hPanel);

    }

    public class Item extends Button{

    public Item(String txt, DragController dragController) {
        super();
        this.setHTML(txt);

        addClickHandler(new ClickHandler(){
        @Override
        public void onClick(ClickEvent event) {
            System.err.println("Clicked!");
        }

        });

        dragController.makeDraggable(this);
    }
    }
}

//-----------------------------------------------------------

If the Item class extends Button instead, everything works as expected.

Original issue reported on code.google.com by luxferr...@gmail.com on 1 Oct 2011 at 8:05

GoogleCodeExporter commented 9 years ago

Original comment by fredsa on 31 Jan 2012 at 6:00