View Javadoc
1   /*
2    * Copyright 2010 Daniel Kurka
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    * 
7    * http://www.apache.org/licenses/LICENSE-2.0
8    * 
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11   * or implied. See the License for the specific language governing permissions and limitations under
12   * the License.
13   */
14  package com.googlecode.mgwt.dom.client.event.touch;
15  
16  import com.google.gwt.core.client.JsArray;
17  import com.google.gwt.dom.client.NativeEvent;
18  import com.google.gwt.event.dom.client.DomEvent;
19  import com.google.gwt.event.shared.EventHandler;
20  import com.googlecode.mgwt.collection.client.JsLightArray;
21  import com.googlecode.mgwt.collection.shared.LightArray;
22  
23  /**
24   * BaseClass for all TouchEvents
25   * 
26   * @author Daniel Kurka
27   * @param <H> the event handler to associate with this event
28   * @version $Id: $
29   */
30  public abstract class TouchEvent<H extends EventHandler> extends DomEvent<H> {
31  
32    /**
33     * <p>
34     * touches
35     * </p>
36     * 
37     * @deprecated use {@link #getTouches()} this method will be removed in a future release
38     * 
39     * @return a {@link com.google.gwt.core.client.JsArray} object.
40     */
41    @Deprecated
42    public JsArray<JsTouch> touches() {
43      return touches(getNativeEvent());
44    }
45  
46    public LightArray<Touch> getTouches() {
47      return new JsLightArray<Touch>(getNativeEvent().getTouches());
48    }
49  
50    /**
51     * <p>
52     * touches
53     * </p>
54     * 
55     * @param nativeEvent a {@link com.google.gwt.dom.client.NativeEvent} object.
56     * @return a {@link com.google.gwt.core.client.JsArray} object.
57     */
58    protected native JsArray<JsTouch> touches(NativeEvent nativeEvent) /*-{
59  		return nativeEvent.touches;
60    }-*/;
61  
62    /**
63     * get the changed touches
64     * 
65     * @deprecated use {@link #getChangedTouches()}
66     * 
67     *             this method will be removed in a future release
68     * 
69     * @return the array of changed touches
70     */
71    @Deprecated
72    public JsArray<JsTouch> changedTouches() {
73      return changedTouches(getNativeEvent());
74    }
75  
76    public LightArray<Touch> getChangedTouches() {
77      return new JsLightArray<Touch>(getNativeEvent().getChangedTouches());
78    }
79  
80    /**
81     * <p>
82     * changedTouches
83     * </p>
84     * 
85     * @param nativeEvent a {@link com.google.gwt.dom.client.NativeEvent} object.
86     * @return a {@link com.google.gwt.core.client.JsArray} object.
87     */
88    protected native JsArray<JsTouch> changedTouches(NativeEvent nativeEvent) /*-{
89  		return nativeEvent.changedTouches;
90    }-*/;
91  
92  }