views:

450

answers:

3

Hi,

I am using gwt graphics and gwt dnd for a program. I have a button which when clicked creates a circle at specified position on the panel and the circle is draggable. For dragging i have used gwt-dnd. I have also added a click handler to the circle which when click should print "ERD Circle".

Here is the code layout:

 Button b = new Button("Circle");
 b.addClickHandler(new ClickHandler(){
  @Override
  public void onClick(ClickEvent event) {
   // TODO Auto-generated method stub
      Circle c = new Circle(20, 15, 10);
      d.add(c);
      c.addClickHandler(new ClickHandler(){
    @Override
    public void onClick(ClickEvent event) {
     // TODO Auto-generated method stub
     System.out.println("ERD Circle");
    }        
      });
      dragController.makeDraggable(d);
      boundaryPanel.add(d, 200, 200 );
  }   
 });

This button is then added to an absolutepanel which in turn is added to the rootpanel.

Problem that i am facing is click handler does not work when it is made draggable. If i remove

dragController.makeDraggable(d);

click handler works perfectly fine.

Question:

  1. Am i doing anything wrong here?
  2. If the code is correct, then is there anything else that i need to add to get both click handler and draggable working?

Any suggestions will be of great help.

Thank you.

+1  A: 

I got it working. I just added

dragController.setBehaviorDragStartSensitivity(1);

to my code and its fine now.

sprasad12
A: 

Great that you found your answer yourself. I must look at gwt after I left it there rotting a year ago. I hope they finished moving to java 5

RocketSurgeon
A: 

@sprasad12: Your solution helps me to resolve another issue arising from clickhandler interfering with draggable widget in IE. Just to write in to say a big thanks to you :)

Style
I am glad it did :)
sprasad12