Implement ClickHandler in custom Widget

gwt

Solution

If you want your widget to behave like clickable GWT widgets you should use com.google.gwt.event.dom.client.HasClickHandlers interface.

public class MyWidget extends Widget
implements HasClickHandlers
{
    public HandlerRegistration addClickHandler(
        ClickHandler handler)
    {
        return addDomHandler(handler, ClickEvent.getType());
    }
}

Problem

I am creating a custom widget in GWT extending Composite and implementing ClickHandler. I have already implemented the method onClick, but the clickEvent does not work. What method should I additionally implement in the class in order the clickEvent to work? May be HandlerRegistration? How?

Original source