aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/richtextarea/RichTextAreaDelegateToShortcutHandler.java
blob: 4f208a05e6fcf99de3e53d8d3cc623e54cd57161 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.vaadin.tests.components.richtextarea;

import com.vaadin.event.ShortcutAction;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.Button;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.VerticalLayout;

public class RichTextAreaDelegateToShortcutHandler
        extends AbstractTestUIWithLog {

    @Override
    protected void setup(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        final RichTextArea name = new RichTextArea();
        name.setCaption("Type your name here:");

        Button button = new Button("Click Me");
        button.setClickShortcut(ShortcutAction.KeyCode.ENTER);
        button.addClickListener(
                e -> log("ShortcutHandler invoked " + name.getValue()));

        layout.addComponents(name, button);
        addComponent(layout);
    }
}