]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test application for Button click mouse event #6605
authorJohn Alhroos <john.ahlroos@itmill.com>
Tue, 26 Apr 2011 12:31:56 +0000 (12:31 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Tue, 26 Apr 2011 12:31:56 +0000 (12:31 +0000)
svn changeset:18467/svn branch:6.6

tests/src/com/vaadin/tests/components/button/ButtonMouseDetails.java [new file with mode: 0644]

diff --git a/tests/src/com/vaadin/tests/components/button/ButtonMouseDetails.java b/tests/src/com/vaadin/tests/components/button/ButtonMouseDetails.java
new file mode 100644 (file)
index 0000000..2882c82
--- /dev/null
@@ -0,0 +1,57 @@
+package com.vaadin.tests.components.button;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class ButtonMouseDetails extends TestBase {
+
+    private Label out = new Label("", Label.CONTENT_PREFORMATTED);
+
+    private int clickCounter = 1;
+
+    @Override
+    protected void setup() {
+
+        Button button = new Button("CLICK ME!", new Button.ClickListener() {
+            @Override
+            public void buttonClick(ClickEvent event) {
+                StringBuilder str = new StringBuilder(out.getValue().toString());
+                str.append(clickCounter + ":\t");
+
+                // Modifier keys
+                str.append("ctrl=" + event.isCtrlKey() + ",\t");
+                str.append("alt=" + event.isAltKey() + ",\t");
+                str.append("meta=" + event.isMetaKey() + ",\t");
+                str.append("shift=" + event.isShiftKey() + ",\t");
+
+                // Coordinates
+                str.append("X=" + event.getRelativeX() + ",\t");
+                str.append("Y=" + event.getRelativeY() + ",\t");
+                str.append("clientX=" + event.getClientX() + ",\t");
+                str.append("clientY=" + event.getClientY());
+
+                str.append("\n");
+
+                out.setValue(str.toString());
+                clickCounter++;
+            }
+        });
+
+        getLayout().setSpacing(true);
+        addComponent(button);
+        addComponent(out);
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Clicking a button should returns some additional information about the click";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 6605;
+    }
+
+}