Sometimes users expect text boxes to move focus on to the next element after pressing Enter, similar to most spreadsheets. If you are using GWT and jQuery, here is a little snippet to help you along:
public class AutoTabbedTextBox extends TextBox implements KeyUpHandler {
public AutoTabbedTextBox() {
super();
addKeyUpHandler(this);
}
@Override
public void onKeyUp(KeyUpEvent event) {
// emulate tab on key
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
focusNext(event.getNativeEvent());
}
public native void focusNext(NativeEvent event)/*-{
var inputs = $wnd.$(':input:visible');
inputs.eq(inputs.index(event.target) + 1).focus();
}-*/;
}
Comments