You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Ticket1365.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.vaadin.tests.tickets;
  2. import com.vaadin.event.Action;
  3. import com.vaadin.event.ShortcutAction;
  4. import com.vaadin.event.Action.Handler;
  5. import com.vaadin.ui.Label;
  6. import com.vaadin.ui.TextField;
  7. import com.vaadin.ui.Window;
  8. public class Ticket1365 extends com.vaadin.Application implements Handler {
  9. TextField f = new TextField();
  10. Label status = new Label("ENTER and CTRL-S fires shortcut action.");
  11. @Override
  12. public void init() {
  13. final Window main = new Window(getClass().getName().substring(
  14. getClass().getName().lastIndexOf(".") + 1));
  15. setMainWindow(main);
  16. main.addComponent(f);
  17. main.addComponent(status);
  18. main.addActionHandler(this);
  19. f.focus();
  20. }
  21. final static private Action[] actions = new Action[] {
  22. new ShortcutAction("Enter", ShortcutAction.KeyCode.ENTER,
  23. new int[] {}),
  24. new ShortcutAction("CTRL-S", ShortcutAction.KeyCode.S,
  25. new int[] { ShortcutAction.ModifierKey.CTRL }), };
  26. public Action[] getActions(Object target, Object sender) {
  27. return actions;
  28. }
  29. public void handleAction(Action action, Object sender, Object target) {
  30. status.setValue("Pressed " + action.getCaption()
  31. + " to fire shortcut. Texfield value: " + f.getValue());
  32. f.focus();
  33. }
  34. }