Search code examples
gwtgxt

Shift the cursor focus on to a textField on checkbox selection


I have a text field and a check box.On selection of the combo box the cursor irrespective of its position should come to the text field.Is it possible

If yes how can it be done in gwt


Solution

  • This will do what you want:

    final TextBox textBox = new TextBox();
    final CheckBox checkBox = new CheckBox();
    
    checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>()
    {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event)
        {
            /* Do something with the event */
    
            /* Then set the focus */
            textBox.setFocus(true);
        }
    });