开发者

Gwt Graphics and ClickHandler

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.ad开发者_运维知识库dClickHandler(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.


I got it working. I just added

dragController.setBehaviorDragStartSensitivity(1);

to my code and its fine now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜