Reputation: 753
I have created a click handler on a gwt label, but it fails to fire. Whats wrong? Same method works for other widgets like icon etc.
@UiField Label fileName;
---
---
public void addClickHandler() {
fileName.sinkEvents(Event.ONCLICK);
handler = this.addHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
event.preventDefault();
event.stopPropagation();
Window.alert("UI clicked");
}
}, ClickEvent.getType());
}
Upvotes: 0
Views: 804
Reputation: 8640
As I pointed out in comment. Reason why it is not working is because you are adding native event handler to this
, and as i but you need to sink DOM events on element to be able to handle them. As you did not do this for this
element but for Label
it won't work.
As You want to handle click element on Label
, you need to add your handler to fileName
and that will work
Upvotes: 2