How can I set focus on next component in the form? For example:
Button button1 = new Button("Button1");
button1.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
button1.???
}
});
I dont know what next components are, and I dont want to know.
In a hard way I would need to check if next components exist. Next step is check if they are focusable or not. For example next component maight be a button (or other input), but it could be placed in <table><tbody><tr><td><button></td></tr></tbody></table> so i would need to do that in recursive way.
Isn’t there a simpler way?
Add all your components into an array, then figure out where you are in the array and set the focus on the next item in the array.
array[x].setFocus(true);
You’ll need to create the array at startup, but otherwise you’ll have control over the order of the items no matter what their layout is in the document.