Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Select next control on ENTER

    Code:
    DynamicForm frmLogin = new DynamicForm();
    TextItem txtUsuario = new TextItem("usuario", "Usuario");
    txtUsuario.setTabIndex(0);
    txtUsuario.addKeyPressHandler(new KeyPressHandler() {
      @Override
      public void onKeyPress(KeyPressEvent event) {
        if ("Enter".equals(event.getKeyName())) {
          frmLogin.focusInItem(cmbOficina);
        }
      }
    });
    where cmbOficina is the next control.

    If you don't know what's the next control (in a base class, for example) you can use the event getForm() method like this
    Code:
    event.getForm().focusInItem(event.getItem().getTabIndex()+1);
    If you use this method, it's important that you set the tabIndex property for each control.
    The previous code isn't aware when it is the last control. Most of the time, we would like to fire the OK button.
Working...
X