1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.googlecode.mgwt.dom.client.event.mouse;
17
18 import com.google.gwt.event.dom.client.MouseDownEvent;
19 import com.google.gwt.event.dom.client.MouseDownHandler;
20 import com.google.gwt.event.dom.client.MouseMoveEvent;
21 import com.google.gwt.event.dom.client.MouseMoveHandler;
22 import com.google.gwt.event.dom.client.MouseUpEvent;
23 import com.google.gwt.event.dom.client.MouseUpHandler;
24 import com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler;
25
26
27
28
29
30
31
32
33 public class TouchMoveToMouseMoveHandler implements MouseMoveHandler, MouseDownHandler, MouseUpHandler {
34
35 private boolean ignoreEvent;
36 private final TouchMoveHandler touchMoveHandler;
37
38
39
40
41
42
43 public TouchMoveToMouseMoveHandler(TouchMoveHandler touchMoveHandler) {
44 this.touchMoveHandler = touchMoveHandler;
45 ignoreEvent = true;
46 }
47
48
49 @Override
50 public void onMouseMove(MouseMoveEvent event) {
51 if (ignoreEvent)
52 return;
53 touchMoveHandler.onTouchMove(new SimulatedTouchMoveEvent(event));
54
55 }
56
57
58
59
60
61 @Override
62 public void onMouseUp(MouseUpEvent event) {
63 ignoreEvent = true;
64
65 }
66
67
68
69
70
71 @Override
72 public void onMouseDown(MouseDownEvent event) {
73 ignoreEvent = false;
74
75 }
76
77 }