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?
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With