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.

ComboBoxCombinedWithEnterShortcut.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.vaadin.tests.components.combobox;
  2. import com.vaadin.event.ShortcutAction.KeyCode;
  3. import com.vaadin.tests.components.TestBase;
  4. import com.vaadin.tests.util.Log;
  5. import com.vaadin.ui.Button;
  6. import com.vaadin.v7.shared.ui.combobox.FilteringMode;
  7. import com.vaadin.v7.ui.ComboBox;
  8. public class ComboBoxCombinedWithEnterShortcut extends TestBase {
  9. final String[] cities = { "Berlin", "Brussels", "Helsinki", "Madrid",
  10. "Oslo", "Paris", "Stockholm" };
  11. private Log log = new Log(5);
  12. @Override
  13. protected void setup() {
  14. final ComboBox l = new ComboBox("Please select a city");
  15. for (String city : cities) {
  16. l.addItem(city);
  17. }
  18. l.setFilteringMode(FilteringMode.OFF);
  19. l.setImmediate(true);
  20. l.setNewItemsAllowed(true);
  21. Button aButton = new Button("Show Value");
  22. aButton.setClickShortcut(KeyCode.ENTER);
  23. aButton.addClickListener(event -> log
  24. .log("Button clicked. ComboBox value: " + l.getValue()));
  25. addComponent(log);
  26. addComponent(l);
  27. addComponent(aButton);
  28. }
  29. @Override
  30. protected String getDescription() {
  31. return "Button has Enter as click shortcut key. The shortcut should not be triggered when selecting an item in the dropdown";
  32. }
  33. @Override
  34. protected Integer getTicketNumber() {
  35. return 6686;
  36. }
  37. }