I have created a custom widget which is basically a HTMLPanel that extends
Composite and is styled as a button.
I'm using the widget with UiBinder, but I want to use the @UiHandler
annotation inside the view where the button
is located and catch its click event.
How can I do this? I have tried doing something like this but it doesn't
work:
@UiField
HTMLPanel mainContainer;
@UiConstructor
public CustomButton(String text)
{
initWidget(binder.createAndBindUi(this));
setText(text);
mainContainer.addDomHandler(new ClickHandler()
{
@Override
public void onClick(ClickEvent event)
{
Window.alert("Clicky");
fireEvent(event);
}
}, ClickEvent.getType());
}
In my view:
@UiHandler("customButton")
public void customButton(ClickEvent event)
{
Window.alert("Clicky!");
}
I get error:
[ERROR] Field 'customButton' does not have an 'addClickHandler' method
associated.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/WpeTLccF-xsJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.