org.eclipse.swt.events.GestureEvent Maven / Gradle / Ivy
Show all versions of org.eclipse.swt.gtk.linux.aarch64 Show documentation
/*******************************************************************************
* Copyright (c) 2010, 2018 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.events;
import org.eclipse.swt.widgets.*;
/**
* Instances of this class are sent in response to
* touch-based gestures that are triggered by the user.
*
* @see GestureListener
* @see Sample code and further information
*
* @since 3.7
*/
public class GestureEvent extends TypedEvent {
/**
* The state of the keyboard modifier keys and mouse masks
* at the time the event was generated.
*
* @see org.eclipse.swt.SWT#MODIFIER_MASK
* @see org.eclipse.swt.SWT#BUTTON_MASK
*/
public int stateMask;
/**
* The gesture type.
*
* - {@link org.eclipse.swt.SWT#GESTURE_BEGIN}
* - {@link org.eclipse.swt.SWT#GESTURE_END}
* - {@link org.eclipse.swt.SWT#GESTURE_MAGNIFY}
* - {@link org.eclipse.swt.SWT#GESTURE_PAN}
* - {@link org.eclipse.swt.SWT#GESTURE_ROTATE}
* - {@link org.eclipse.swt.SWT#GESTURE_SWIPE}
*
*
* This field determines the GestureEvent
fields that contain valid data.
*/
public int detail;
/**
* The meaning of this field is dependent on the value of the detail
field
* and the platform. It can represent either the x coordinate of the centroid of the
* touches that make up the gesture, or the x coordinate of the cursor at the time the
* gesture was performed.
*/
public int x;
/**
* The meaning of this field is dependent on the value of the detail
field
* and the platform. It can represent either the y coordinate of the centroid of the
* touches that make up the gesture, or the y coordinate of the cursor at the time the
* gesture was performed.
*/
public int y;
/**
* This field is valid when the detail
field is set to GESTURE_ROTATE
.
* It specifies the number of degrees rotated on the device since the gesture started. Positive
* values indicate counter-clockwise rotation, and negative values indicate clockwise rotation.
*/
public double rotation;
/**
* This field is valid when the detail
field is set to GESTURE_SWIPE
* or GESTURE_PAN
. Both xDirection
and yDirection
* can be valid for an individual gesture. The meaning of this field is dependent on the value
* of the detail
field.
*
* If detail
is GESTURE_SWIPE
then a positive value indicates a swipe
* to the right and a negative value indicates a swipe to the left.
*
* If detail
is GESTURE_PAN
then a positive value indicates a pan to
* the right by this field's count of points and a negative value indicates a pan to the left
* by this field's count of points.
*/
public int xDirection;
/**
* This field is valid when the detail
field is set to GESTURE_SWIPE
* or GESTURE_PAN
. Both xDirection
and yDirection
* can be valid for an individual gesture. The meaning of this field is dependent on the value
* of the detail
field.
*
* If detail
is GESTURE_SWIPE
then a positive value indicates a downward
* swipe and a negative value indicates an upward swipe.
*
* If detail
is GESTURE_PAN
then a positive value indicates a downward
* pan by this field's count of points and a negative value indicates an upward pan by this
* field's count of points.
*/
public int yDirection;
/**
* This field is valid when the detail
field is set to GESTURE_MAGNIFY
.
* This is the scale factor to be applied. This value will be 1.0 in the first received event with
* GESTURE_MAGNIFY
, and will then fluctuate in subsequent events as the user moves
* their fingers.
*/
public double magnification;
/**
* This flag indicates whether the operation should be allowed.
* Setting it to false
will cancel the operation.
*/
public boolean doit;
static final long serialVersionUID = -8348741538373572182L;
/**
* Constructs a new instance of this class based on the
* information in the given untyped event.
*
* @param e the untyped event containing the information
*/
public GestureEvent(Event e) {
super(e);
this.stateMask = e.stateMask;
this.x = e.x;
this.y = e.y;
this.detail = e.detail;
this.rotation = e.rotation;
this.xDirection = e.xDirection;
this.yDirection = e.yDirection;
this.magnification = e.magnification;
this.doit = e.doit;
}
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the event
*/
@Override
public String toString() {
String string = super.toString ();
return string.substring (0, string.length() - 1) // remove trailing '}'
+ " stateMask=0x" + Integer.toHexString(stateMask)
+ " detail=" + detail
+ " x=" + x
+ " y=" + y
+ " rotation=" + rotation
+ " xDirection=" + xDirection
+ " yDirection=" + yDirection
+ " magnification=" + magnification
+ "}";
}
}