summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2009-05-11 09:19:03 +0000
committerHenri Sara <henri.sara@itmill.com>2009-05-11 09:19:03 +0000
commitadc8c0ad3573272c236040c3a76005b9e73a5737 (patch)
treea3860704dbd5b82dc6af38684b80f8ef79a32722 /src/com/vaadin/terminal/gwt/client/MouseEventDetails.java
parent5abc870dda584d0c2fc47fd5eec4ae3de3fa240e (diff)
downloadvaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.tar.gz
vaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.zip
#2904: initial bulk rename "com.itmill.toolkit" -> "com.vaadin"
- com.itmill.toolkit.external not yet fully renamed svn changeset:7715/svn branch:6.0
Diffstat (limited to 'src/com/vaadin/terminal/gwt/client/MouseEventDetails.java')
-rw-r--r--src/com/vaadin/terminal/gwt/client/MouseEventDetails.java93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java b/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java
new file mode 100644
index 0000000000..175dfd8ce2
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java
@@ -0,0 +1,93 @@
+package com.vaadin.terminal.gwt.client;
+
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Event;
+
+/**
+ * Helper class to store and transfer mouse event details.
+ */
+public class MouseEventDetails {
+ public static final int BUTTON_LEFT = Event.BUTTON_LEFT;
+ public static final int BUTTON_MIDDLE = Event.BUTTON_MIDDLE;
+ public static final int BUTTON_RIGHT = Event.BUTTON_RIGHT;
+
+ private static final char DELIM = ',';
+
+ private int button;
+ private int clientX;
+ private int clientY;
+ private boolean altKey;
+ private boolean ctrlKey;
+ private boolean metaKey;
+ private boolean shiftKey;
+ private int type;
+
+ public int getButton() {
+ return button;
+ }
+
+ public int getClientX() {
+ return clientX;
+ }
+
+ public int getClientY() {
+ return clientY;
+ }
+
+ public boolean isAltKey() {
+ return altKey;
+ }
+
+ public boolean isCtrlKey() {
+ return ctrlKey;
+ }
+
+ public boolean isMetaKey() {
+ return metaKey;
+ }
+
+ public boolean isShiftKey() {
+ return shiftKey;
+ }
+
+ public MouseEventDetails(Event evt) {
+ button = DOM.eventGetButton(evt);
+ clientX = DOM.eventGetClientX(evt);
+ clientY = DOM.eventGetClientY(evt);
+ altKey = DOM.eventGetAltKey(evt);
+ ctrlKey = DOM.eventGetCtrlKey(evt);
+ metaKey = DOM.eventGetMetaKey(evt);
+ shiftKey = DOM.eventGetShiftKey(evt);
+ type = DOM.eventGetType(evt);
+ }
+
+ private MouseEventDetails() {
+ }
+
+ @Override
+ public String toString() {
+ return "" + button + DELIM + clientX + DELIM + clientY + DELIM + altKey
+ + DELIM + ctrlKey + DELIM + metaKey + DELIM + shiftKey + DELIM
+ + type;
+ }
+
+ public static MouseEventDetails deSerialize(String serializedString) {
+ MouseEventDetails instance = new MouseEventDetails();
+ String[] fields = serializedString.split(",");
+
+ instance.button = Integer.parseInt(fields[0]);
+ instance.clientX = Integer.parseInt(fields[1]);
+ instance.clientY = Integer.parseInt(fields[2]);
+ instance.altKey = Boolean.valueOf(fields[3]).booleanValue();
+ instance.ctrlKey = Boolean.valueOf(fields[4]).booleanValue();
+ instance.metaKey = Boolean.valueOf(fields[5]).booleanValue();
+ instance.shiftKey = Boolean.valueOf(fields[6]).booleanValue();
+ instance.type = Integer.parseInt(fields[7]);
+ return instance;
+ }
+
+ public boolean isDoubleClick() {
+ return type == Event.ONDBLCLICK;
+ }
+
+}