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.events;
17 import org.eclipse.swt.widgets.*;
20 * Instances of this class are sent in response to
21 * a touch-based input source being touched.
24 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
28 public class TouchEvent extends TypedEvent {
31 * The set of touches representing the state of all contacts with touch input
32 * device at the time the event was generated.
34 * @see org.eclipse.swt.widgets.Touch
36 public Touch[] touches;
39 * The state of the keyboard modifier keys and mouse masks
40 * at the time the event was generated.
42 * @see org.eclipse.swt.SWT#MODIFIER_MASK
43 * @see org.eclipse.swt.SWT#BUTTON_MASK
48 * The widget-relative x coordinate of the pointer
49 * at the time the touch occurred.
54 * The widget-relative y coordinate of the pointer
55 * at the time the touch occurred.
59 static final long serialVersionUID = -8348741538373572182L;
62 * Constructs a new instance of this class based on the
63 * information in the given untyped event.
65 * @param e the untyped event containing the information
67 public TouchEvent(Event e) {
69 this.touches = e.touches;
70 this.stateMask = e.stateMask;
76 * Returns a string containing a concise, human-readable
77 * description of the receiver.
79 * @return a string representation of the event
82 public String toString() {
83 String string = super.toString();
84 string = string.substring (0, string.length() - 1); // remove trailing '}'
85 string += " stateMask=0x" + Integer.toHexString(stateMask)
88 if (touches != null) {
89 for (int i = 0; i < touches.length; i++) {
90 string += "\n " + touches[i].toString();