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.

FocusFromShortcutAction.java 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.vaadin.tests.components;
  2. import java.util.Arrays;
  3. import com.vaadin.event.ShortcutAction.KeyCode;
  4. import com.vaadin.event.ShortcutAction.ModifierKey;
  5. import com.vaadin.ui.Button;
  6. import com.vaadin.ui.Button.ClickEvent;
  7. import com.vaadin.ui.Select;
  8. import com.vaadin.ui.TextField;
  9. public class FocusFromShortcutAction extends TestBase {
  10. @Override
  11. protected void setup() {
  12. final Select select = new Select("Select", Arrays.asList("Option 1",
  13. "Option 2"));
  14. final TextField text = new TextField("Text");
  15. addComponent(select);
  16. addComponent(text);
  17. Button focusText = new Button("Focus text", new Button.ClickListener() {
  18. @Override
  19. public void buttonClick(ClickEvent event) {
  20. text.focus();
  21. }
  22. });
  23. focusText.setClickShortcut(KeyCode.T, ModifierKey.ALT);
  24. addComponent(focusText);
  25. Button focusSelect = new Button("Focus select",
  26. new Button.ClickListener() {
  27. @Override
  28. public void buttonClick(ClickEvent event) {
  29. select.focus();
  30. }
  31. });
  32. focusSelect.setClickShortcut(KeyCode.S, ModifierKey.ALT);
  33. addComponent(focusSelect);
  34. }
  35. @Override
  36. protected String getDescription() {
  37. return "The option drop down of the Focus select should not be opened when the \"Focus select\" button is triggered by clicking it with the mouse or with the associated shortcut key Alt + S";
  38. }
  39. @Override
  40. protected Integer getTicketNumber() {
  41. return Integer.valueOf(7539);
  42. }
  43. }