Reputation: 267
When I'm adding a clickhandler to a button, im doing it like this:
button.addClickHandler(myHandler);
// myHandler
public void onClick(ClickEvent event) {
// how to get the button here?
}
Does anyone know how I can get the button object that has been clicked inside the clickhandler?
Upvotes: 3
Views: 3516
Reputation: 4061
You can write
Widget sender = (Widget) event.getSource();
Then, for each button, compare it to sender:
private Button b = new Button("Button XXX");
if (sender == b) {
// handle Button XXX being clicked
}
Upvotes: 5