I have a text widget where I want to make enter event to behave like a tab event. so I capture the Key press event and raise a tab native event.
However the tab behavior is not reflected in the application. The code for event handler is
public void onKeyPress(KeyPressEvent event) {
int keyCode = event.getNativeEvent().getKeyCode();
if (keyCode == KeyCodes.KEY_ENTER) {
NativeEvent nativeEvent =
Document.get().
createKeyPressEvent(false,false,false,false,KeyCodes.KEY_TAB );
DomEvent.fireNativeEvent(nativeEvent, this, this.getElement());
}
When I use the deprecated createKeyPressEvent with more argument, it fires the tab event but the behavior is not as per the tab key press, which is to move to next widget. The new code changes from the above code in createKeyPress event line as follows
NativeEvent nativeEvent =
Document.get().
createKeyPressEvent(false,false,false,false,
KeyCodes.KEY_TAB ,KeyCodes.KEY_TAB);