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.

ButtonMouseDetails.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package com.vaadin.tests.components.button;
  2. import com.vaadin.shared.ui.ContentMode;
  3. import com.vaadin.tests.components.TestBase;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.Button.ClickEvent;
  6. import com.vaadin.ui.Label;
  7. public class ButtonMouseDetails extends TestBase {
  8. private Label out = new Label("", ContentMode.PREFORMATTED);
  9. private int clickCounter = 1;
  10. private Button.ClickListener clickListener = new Button.ClickListener() {
  11. @Override
  12. public void buttonClick(ClickEvent event) {
  13. StringBuilder str = new StringBuilder(out.getValue().toString());
  14. str.append(clickCounter + ":\t");
  15. // Modifier keys
  16. str.append("ctrl=" + event.isCtrlKey() + ",\t");
  17. str.append("alt=" + event.isAltKey() + ",\t");
  18. str.append("meta=" + event.isMetaKey() + ",\t");
  19. str.append("shift=" + event.isShiftKey() + ",\t");
  20. // Coordinates
  21. str.append("X=" + event.getRelativeX() + ",\t");
  22. str.append("Y=" + event.getRelativeY() + ",\t");
  23. str.append("clientX=" + event.getClientX() + ",\t");
  24. str.append("clientY=" + event.getClientY());
  25. str.append("\n");
  26. out.setValue(str.toString());
  27. clickCounter++;
  28. }
  29. };
  30. @Override
  31. protected void setup() {
  32. getLayout().setSpacing(true);
  33. Button button = new Button("CLICK ME!", clickListener);
  34. addComponent(button);
  35. addComponent(out);
  36. }
  37. @Override
  38. protected String getDescription() {
  39. return "Clicking a button should returns some additional information about the click";
  40. }
  41. @Override
  42. protected Integer getTicketNumber() {
  43. return 6605;
  44. }
  45. }