Example usage for com.vaadin.ui AbstractField addShortcutListener

List of usage examples for com.vaadin.ui AbstractField addShortcutListener

Introduction

In this page you can find the example usage for com.vaadin.ui AbstractField addShortcutListener.

Prototype

public Registration addShortcutListener(ShortcutListener shortcut) 

Source Link

Usage

From source file:com.shopwiki.vaadin.InlineForm.java

License:Apache License

protected InlineForm(final AbstractField field, String submitCaption, Handler<T> handler) {
    this.field = field;
    this.handler = handler;

    Button submitButton = new Button(submitCaption, this, "handle");

    //submitButton.setClickShortcut(KeyCode.ENTER);
    // Putting the shortcut listener on the textField is better since it can check it the textField is the target
    field.addShortcutListener(new ShortcutListener(submitCaption, KeyCode.ENTER, null) {
        @Override/*from w  ww. j  ava 2s  . c o m*/
        public void handleAction(Object sender, Object target) {
            if (target == field) {
                handle();
            }
        }
    });

    addComponent(field);
    addComponent(submitButton);
    setSpacing(true);
}