Hi,
I need a detect enter key when valuechange listener for textfield in vaadin 8. I needs trigger if user click enter key from textfield. I know I can use shortcut key for that. But I have multiple textfield where need to detect enter key press and trigger to one other component.
So please anyone know, how can I detect Enter key inside of valuechangelistener for Textfield in vaadin 8.
Just like Haijian suggested, you can achieve that by creating a simple extension for the TextField. Here is a working example on how to extend the text field and handle the enter key pressed event on the server.
public interface TextFieldExtensionServerRpc extends ServerRpc {
public void enterKeyPressed();
}
[/code]Then, in your code you just have to extend your text field such as:
TextField myTextField = new TextField();
TextFieldExtension extension = new TextFieldExtension(myTextField);
Hope this helps,
Goran
I know you didn’t mention it specifically, but on the off chance that you want to mimic Vaadin 7 ValueChangeEvent behaviour, note that you also need to consider tabulator and clicking outside of the field.
The TextFieldExtensionServerRpc and TextFieldExtensionConnector should be put into client folder because those two files need to be compiled into widgetset.
You can move those two files to com.example.add_on_myapplication.client folder.