blob: 175dfd8ce2ece8c90be1e2e15aea80d9156c2974 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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;
}
}
|