12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package com.vaadin.tests.components.button;
-
- import com.vaadin.event.Action;
- import com.vaadin.event.Action.Handler;
- import com.vaadin.event.ShortcutAction;
- import com.vaadin.tests.components.TestBase;
- import com.vaadin.tests.util.Log;
- import com.vaadin.ui.Button;
-
- public class ButtonEnterWithWindowShortcut extends TestBase {
- Log log = new Log(5);
-
- @Override
- protected void setup() {
- getMainWindow().addActionHandler(new Handler() {
- private static final long serialVersionUID = -4976129418325394913L;
-
- @Override
- public void handleAction(Action action, Object sender,
- Object target) {
- log.log(action.getCaption() + " pressed in window");
- }
-
- @Override
- public Action[] getActions(Object target, Object sender) {
- ShortcutAction enter = new ShortcutAction("enter",
- ShortcutAction.KeyCode.ENTER, null);
- ShortcutAction space = new ShortcutAction("space",
- ShortcutAction.KeyCode.SPACEBAR, null);
- return new Action[] { enter, space };
- }
- });
-
- Button button = new Button("Focus me and press enter",
- event -> log.log("button click listener fired"));
- button.focus();
-
- addComponent(log);
- addComponent(button);
- }
-
- @Override
- protected String getDescription() {
- return "Pressing enter or space with the button focused should trigger the button click listener and not the shortcut action on the window.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return Integer.valueOf(5433);
- }
-
- }
|