i have this class for my input textbox:
class InputTextBox extends FlowPanel {
public InputTextBox(String labelText) {
super();
Label label = new Label(labelText);
TextBox input = new TextBox();
this.add(label);
this.add(input);
this.addStyleName("myBox");
}
}
How do I set focus on that textbox so when onmoduleload is called the cursor appears in the textbox? Adding a member function seems to throw many errors.
public void setFocus(boolean b) {
this.setFocus(b);
}
You should add this block to constructor or onLoad method:
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
//call setFocus method here:
input.setFocus(true);
}});
Make a property field for you TextBox and in your setFocus method call textBox.setFocus(true), or whatever you called your TextBox property.
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