views:

218

answers:

1

hi..am relatively very new to gwt n dnd.. i have created a composite widget.. when i try to make the object of the composite widget draggable it throws an exception "dragHandle must implement HasMouseDownHandlers, HasMouseUpHandlers, HasMouseMoveHandlers and HasMouseOutHandlers to be draggable" am i missing something very importand?

Thanks, sindhu

+2  A: 

You can implement them like this:

public class MyWidget extends Composite implements HasAllMouseHandlers, HasClickHandlers {

...

      public HandlerRegistration addClickHandler(ClickHandler handler) {
        return addDomHandler(handler, ClickEvent.getType());
      }

      public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
          return addDomHandler(handler, MouseDownEvent.getType());
      }

      public HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler) {
        return addDomHandler(handler, MouseMoveEvent.getType());
      }

      public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
        return addDomHandler(handler, MouseOutEvent.getType());
      }

      public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
        return addDomHandler(handler, MouseOverEvent.getType());
      }

      public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
        return addDomHandler(handler, MouseUpEvent.getType());
      }

      public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) {
        return addDomHandler(handler, MouseWheelEvent.getType());
      }

}

To get your widget d'n'd working, see this http://groups.google.com/group/gwt-dnd/browse%5Fthread/thread/85039aaa229d53cf/f5ad10ff9a37ab9d?lnk=gst&q=custom+widget#f5ad10ff9a37ab9d

Marius Andreiana
Thanks for ur response :) it did helped me a lot..
sindhu