public final class TouchEvent extends InputEvent
Touch point represents a single touched finger and has its location,
state (pressed/moved/released/stationary) and an ID unique in scope of a
single gesture. For detailed reference see TouchPoint
.
For each multi-touch action a set of touch events is generated - for each
touch point one. The event has type corresponds to its touch point's state.
Each of the events also contain
list of all the touch points. This design allows for handling complicated
multi-touch actions from one place while keeping it possible to
filter/consume each touch point separately. To recognize
which events belong into a single set there is getEventSetId()
method.
Each touch point is - similarly to mouse dragging - delivered to a single
node on which it was pressed, regardless of where it moves then. It is
possible to change this behavior by using a grabbing mechanism described
in TouchPoint
documentation.
Modifier and Type | Field and Description |
---|---|
private boolean |
altDown
Whether or not the Alt modifier is down on this event.
|
static <any> |
ANY
Common supertype for all touch event types.
|
private boolean |
controlDown
Whether or not the Control modifier is down on this event.
|
private int |
eventSetId |
private boolean |
metaDown
Whether or not the Meta modifier is down on this event.
|
private static long |
serialVersionUID |
private boolean |
shiftDown
Whether or not the Shift modifier is down on this event.
|
static <any> |
TOUCH_MOVED
This event occurs when the touch point is moved.
|
static <any> |
TOUCH_PRESSED
This event occurs when the touch point is pressed (touched for the
first time).
|
static <any> |
TOUCH_RELEASED
This event occurs when the touch point is released.
|
static <any> |
TOUCH_STATIONARY
This event occurs when the touch point is pressed and still (doesn't
move).
|
private TouchPoint |
touchPoint |
private java.util.List<TouchPoint> |
touchPoints |
Constructor and Description |
---|
TouchEvent(<any> eventType,
TouchPoint touchPoint,
java.util.List<TouchPoint> touchPoints,
int eventSetId,
boolean shiftDown,
boolean controlDown,
boolean altDown,
boolean metaDown)
Constructs new TouchEvent event with null source and target.
|
TouchEvent(java.lang.Object source,
EventTarget target,
<any> eventType,
TouchPoint touchPoint,
java.util.List<TouchPoint> touchPoints,
int eventSetId,
boolean shiftDown,
boolean controlDown,
boolean altDown,
boolean metaDown)
Constructs new TouchEvent event.
|
Modifier and Type | Method and Description |
---|---|
TouchEvent |
copyFor(java.lang.Object newSource,
EventTarget newTarget) |
TouchEvent |
copyFor(java.lang.Object newSource,
EventTarget newTarget,
<any> type)
Creates a copy of the given event with the given fields substituted.
|
int |
getEventSetId()
Gets sequential number of the set of touch events representing the same
multi-touch action.
|
<any> |
getEventType() |
int |
getTouchCount()
Returns number of touch points represented by this touch event set.
|
TouchPoint |
getTouchPoint()
Gets the touch point of this event.
|
java.util.List<TouchPoint> |
getTouchPoints()
Gets all the touch points represented by this set of touch events,
including the touch point of this event.
|
boolean |
isAltDown()
Whether or not the Alt modifier is down on this event.
|
boolean |
isControlDown()
Whether or not the Control modifier is down on this event.
|
boolean |
isMetaDown()
Whether or not the Meta modifier is down on this event.
|
boolean |
isShiftDown()
Whether or not the Shift modifier is down on this event.
|
private static void |
recomputeToSource(TouchEvent event,
java.lang.Object oldSource,
java.lang.Object newSource)
Recomputes touch event for the given event source object.
|
java.lang.String |
toString()
Returns a string representation of this
TouchEvent object. |
private static final long serialVersionUID
public static final <any> ANY
public static final <any> TOUCH_PRESSED
public static final <any> TOUCH_MOVED
public static final <any> TOUCH_RELEASED
public static final <any> TOUCH_STATIONARY
private final int eventSetId
private final boolean shiftDown
private final boolean controlDown
private final boolean altDown
private final boolean metaDown
private final TouchPoint touchPoint
private final java.util.List<TouchPoint> touchPoints
public TouchEvent(java.lang.Object source, EventTarget target, <any> eventType, TouchPoint touchPoint, java.util.List<TouchPoint> touchPoints, int eventSetId, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown)
source
- the source of the event. Can be null.target
- the target of the event. Can be null.eventType
- The type of the event.touchPoint
- the touch point of this eventtouchPoints
- set of touch points for the multi-touch actioneventSetId
- set id of the multi-touch actionshiftDown
- true if shift modifier was pressed.controlDown
- true if control modifier was pressed.altDown
- true if alt modifier was pressed.metaDown
- true if meta modifier was pressed.public TouchEvent(<any> eventType, TouchPoint touchPoint, java.util.List<TouchPoint> touchPoints, int eventSetId, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown)
eventType
- The type of the event.touchPoint
- the touch point of this eventtouchPoints
- set of touch points for the multi-touch actioneventSetId
- set id of the multi-touch actionshiftDown
- true if shift modifier was pressed.controlDown
- true if control modifier was pressed.altDown
- true if alt modifier was pressed.metaDown
- true if meta modifier was pressed.public int getTouchCount()
touchPoints
list.private static void recomputeToSource(TouchEvent event, java.lang.Object oldSource, java.lang.Object newSource)
event
- Event to modifyoldSource
- Source object of the current valuesnewSource
- Source object to compute values forpublic TouchEvent copyFor(java.lang.Object newSource, EventTarget newTarget)
public TouchEvent copyFor(java.lang.Object newSource, EventTarget newTarget, <any> type)
newSource
- the new source of the copied eventnewTarget
- the new target of the copied eventtype
- the new eventTypepublic <any> getEventType()
getEventType
in class InputEvent
public final int getEventSetId()
public final boolean isShiftDown()
public final boolean isControlDown()
public final boolean isAltDown()
public final boolean isMetaDown()
public TouchPoint getTouchPoint()
public java.util.List<TouchPoint> getTouchPoints()
belongsTo
method can be used.public java.lang.String toString()
TouchEvent
object.TouchEvent
object.