1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.googlecode.mgwt.ui.client.widget.touch;
17
18 import com.google.gwt.event.dom.client.MouseDownEvent;
19 import com.google.gwt.event.dom.client.MouseMoveEvent;
20 import com.google.gwt.event.dom.client.MouseUpEvent;
21 import com.google.gwt.event.shared.HandlerRegistration;
22 import com.google.gwt.user.client.ui.Widget;
23 import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection;
24 import com.googlecode.mgwt.dom.client.event.mouse.TouchEndToMouseUpHandler;
25 import com.googlecode.mgwt.dom.client.event.mouse.TouchMoveToMouseMoveHandler;
26 import com.googlecode.mgwt.dom.client.event.mouse.TouchStartToMouseDownHandler;
27 import com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler;
28 import com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler;
29 import com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler;
30 import com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler;
31 import com.googlecode.mgwt.ui.client.util.NoopHandlerRegistration;
32
33
34
35
36
37
38
39 public class TouchWidgetDesktopImpl implements TouchWidgetImpl {
40
41
42
43
44
45
46 @Override
47 public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler) {
48 return w.addDomHandler(new TouchStartToMouseDownHandler(handler), MouseDownEvent.getType());
49 }
50
51
52
53
54
55
56 @Override
57 public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler) {
58 TouchMoveToMouseMoveHandler touchMoveToMouseMoveHandler = new TouchMoveToMouseMoveHandler(handler);
59 HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection();
60 handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseDownEvent.getType()));
61 handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseUpEvent.getType()));
62 handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseMoveEvent.getType()));
63 return handlerRegistrationCollection;
64 }
65
66
67
68
69
70
71 @Override
72 public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler handler) {
73 return new NoopHandlerRegistration();
74 }
75
76
77
78
79
80
81 @Override
82 public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler) {
83 return w.addDomHandler(new TouchEndToMouseUpHandler(handler), MouseUpEvent.getType());
84 }
85
86 }