Search code examples
gwthandlergwt-designergwt-widgets

Custom widgets and @UiHandler


Is it possible to have a custom widget use the @UiHandler notation for mouse events? e.g. when using GWT Designer could you right click on the custom widget, select add event handler, then select onClick. Rather than just onAttachOrDetach.

Regards Alex


Solution

  • I don't know how exactly GWT Designer detects those things, but @UiHandler looks at the event argument's type to determine the event handler type and then looks at the type of the ui:field referened in the @UiHandler for a method returning a HandlerRegistration and taking a single argument of the event handler type.

    In brief: you can very well use @UiHandler with your own custom widgets, I just don't know how well GWT Designer supports this.

    See http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java