1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.widgets;
17 * Instances of this class are created in response to a
18 * touch-based input device being touched. They are found
19 * in the <code>touches</code> field of an Event or TouchEvent.
21 * @see org.eclipse.swt.events.TouchEvent
22 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
26 public final class Touch {
29 * The unique identity of the touch. Use this value to track changes to a touch
30 * during the touch's life. Two touches may have the same identity even if they
31 * come from different sources.
36 * The object representing the input source that generated the touch.
38 public TouchSource source;
41 * The state of this touch at the time it was generated. If this field is 0
42 * then the finger is still touching the device but has not moved
43 * since the last <code>TouchEvent</code> was generated.
45 * @see org.eclipse.swt.SWT#TOUCHSTATE_DOWN
46 * @see org.eclipse.swt.SWT#TOUCHSTATE_MOVE
47 * @see org.eclipse.swt.SWT#TOUCHSTATE_UP
52 * A flag indicating that the touch is the first touch from a previous
53 * state of no touch points. Once designated as such, the touch remains
54 * the primary touch until all fingers are removed from the device.
56 public boolean primary;
59 * The x location of the touch in TouchSource coordinates.
64 * The y location of the touch in TouchSource coordinates.
69 * Constructs a new touch state from the given inputs.
71 * @param identity Identity of the touch
72 * @param source Object representing the device that generated the touch
73 * @param state One of the state constants representing the state of this touch
74 * @param primary Whether or not the touch is the primary touch
75 * @param x X location of the touch in screen coordinates
76 * @param y Y location of the touch in screen coordinates
78 Touch (long identity, TouchSource source, int state, boolean primary, int x, int y) {
82 this.primary = primary;
88 * Returns a string containing a concise, human-readable
89 * description of the receiver.
91 * @return a string representation of the event
94 public String toString() {
95 return "Touch {id=" + id
98 + " primary=" + primary