View Javadoc
1   /*
2    * Copyright 2010 Daniel Kurka
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    * 
8    * http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package com.googlecode.mgwt.dom.client.event.tap;
17  
18  import com.google.gwt.dom.client.Element;
19  import com.google.gwt.event.shared.GwtEvent;
20  
21  /**
22   * TapEvent is considered an activation event something like a normal
23   * "click event". Like a button, but with touch events.
24   * 
25   * 
26   * @author Daniel Kurka
27   */
28  
29  public class TapEvent extends GwtEvent<TapHandler> {
30  
31  	private static final Type<TapHandler> TYPE = new Type<TapHandler>();
32  	private final int startX;
33  	private final int startY;
34  	private final Element targetElement;
35  
36  	/**
37  	 * @deprecated use {@link #TapEvent(Object, Element, int, int)} instead
38  	 */
39  	@Deprecated
40  	public TapEvent(Object source, int startX, int startY) {
41  	  this(source, null, startX, startY);
42  	}
43  
44  	public TapEvent(Object source, Element targetElement, int startX, int startY) {
45  	  this.targetElement = targetElement;
46      this.startX = startX;
47      this.startY = startY;
48      setSource(source);
49    }
50  
51    /*
52  	 * (non-Javadoc)
53  	 * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
54  	 */
55  	@Override
56  	public com.google.gwt.event.shared.GwtEvent.Type<TapHandler> getAssociatedType() {
57  		return TYPE;
58  	}
59  
60  	/*
61  	 * (non-Javadoc)
62  	 * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
63  	 */
64  	@Override
65  	protected void dispatch(TapHandler handler) {
66  		handler.onTap(this);
67  
68  	}
69  
70  	public static Type<TapHandler> getType() {
71  		return TYPE;
72  	}
73  
74  	/**
75  	 * get the x start position of the tap
76  	 * 
77  	 * @return the x start position of the tap
78  	 */
79  	public int getStartX() {
80  		return startX;
81  	}
82  
83  	/**
84  	 * get the y start position of the tap
85  	 * 
86  	 * @return the y start position of the tap
87  	 */
88  	public int getStartY() {
89  		return startY;
90  	}
91  	
92  	/**
93  	 * Returns the element that was the actual target of the Tap event.
94  	 */
95  	public Element getTargetElement() {
96      return targetElement;
97    }
98  
99  }