APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene.input

public final Class TouchEvent

extends InputEvent
Class Inheritance
Imports
java.util.Collections, .List, javafx.beans.NamedArg, javafx.event.EventTarget, .EventType

Touch event indicates a touch screen action. It contains detailed information about each particular touch point.

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.

Since
JavaFX 2.2

Field Summary

Modifier and TypeField and Description
private final boolean
altDown

Whether or not the Alt modifier is down on this event.

public static final EventType<TouchEvent>
ANY

Hides javafx.scene.input.InputEvent.ANY.

Common supertype for all touch event types.
private final boolean
controlDown

Whether or not the Control modifier is down on this event.

private final int
private final boolean
metaDown

Whether or not the Meta modifier is down on this event.

private static final long
private final boolean
shiftDown

Whether or not the Shift modifier is down on this event.

public static final EventType<TouchEvent>
TOUCH_MOVED

This event occurs when the touch point is moved.

public static final EventType<TouchEvent>
TOUCH_PRESSED

This event occurs when the touch point is pressed (touched for the first time).

public static final EventType<TouchEvent>
TOUCH_RELEASED

This event occurs when the touch point is released.

public static final EventType<TouchEvent>
TOUCH_STATIONARY

This event occurs when the touch point is pressed and still (doesn't move).

private final TouchPoint
private final List<TouchPoint>

Constructor Summary

AccessConstructor and Description
public
TouchEvent(Object
the source of the event. Can be null.
source
,
EventTarget
the target of the event. Can be null.
target
,
EventType<TouchEvent>
The type of the event.
eventType
,
TouchPoint
the touch point of this event
touchPoint
,
List<TouchPoint>
set of touch points for the multi-touch action
touchPoints
,
int
set id of the multi-touch action
eventSetId
,
boolean
true if shift modifier was pressed.
shiftDown
,
boolean
true if control modifier was pressed.
controlDown
,
boolean
true if alt modifier was pressed.
altDown
,
boolean
true if meta modifier was pressed.
metaDown
)

Constructs new TouchEvent event.

public
TouchEvent(EventType<TouchEvent>
The type of the event.
eventType
,
TouchPoint
the touch point of this event
touchPoint
,
List<TouchPoint>
set of touch points for the multi-touch action
touchPoints
,
int
set id of the multi-touch action
eventSetId
,
boolean
true if shift modifier was pressed.
shiftDown
,
boolean
true if control modifier was pressed.
controlDown
,
boolean
true if alt modifier was pressed.
altDown
,
boolean
true if meta modifier was pressed.
metaDown
)

Constructs new TouchEvent event with null source and target.

Method Summary

Modifier and TypeMethod and Description
public TouchEvent

Returns:

the event copy with the new source and target
copyFor
(Object newSource, EventTarget newTarget)

Overrides javafx.event.Event.copyFor.

Creates and returns a copy of this event with the specified event source and target.

public TouchEvent

Returns:

the event copy with the fields substituted
copyFor
(Object
the new source of the copied event
newSource
,
EventTarget
the new target of the copied event
newTarget
,
EventType<TouchEvent>
the new eventType
type
)

Creates a copy of the given event with the given fields substituted.

public final int

Returns:

Sequential id of event set unique in scope of a gesture
getEventSetId
()

Gets sequential number of the set of touch events representing the same multi-touch action.

public EventType<TouchEvent>
getEventType()

Overrides javafx.scene.input.InputEvent.getEventType.

Gets the event type of this event.

public int

Returns:

The number of touch points represented by this touch event set.
getTouchCount
()

Returns number of touch points represented by this touch event set.

public TouchPoint

Returns:

Touch point of this event
getTouchPoint
()

Gets the touch point of this event.

public List<TouchPoint>

Returns:

All current touch points in an unmodifiable list
getTouchPoints
()

Gets all the touch points represented by this set of touch events, including the touch point of this event.

public final boolean

Returns:

true if the Alt modifier is down on this event
isAltDown
()

Whether or not the Alt modifier is down on this event.

public final boolean

Returns:

true if the Control modifier is down on this event
isControlDown
()

Whether or not the Control modifier is down on this event.

public final boolean

Returns:

true if the Meta modifier is down on this event
isMetaDown
()

Whether or not the Meta modifier is down on this event.

public final boolean

Returns:

true if the Shift modifier is down on this event
isShiftDown
()

Whether or not the Shift modifier is down on this event.

private static void
recomputeToSource(TouchEvent
Event to modify
event
,
Object
Source object of the current values
oldSource
,
Object
Source object to compute values for
newSource
)

Recomputes touch event for the given event source object.

public String

Returns:

a string representation of this TouchEvent object.
toString
()

Overrides java.util.EventObject.toString.

Returns a string representation of this TouchEvent object.

Field Detail

altDownback to summary
private final boolean altDown

Whether or not the Alt modifier is down on this event.

ANYback to summary
public static final EventType<TouchEvent> ANY

Hides javafx.scene.input.InputEvent.ANY.

Common supertype for all touch event types.

controlDownback to summary
private final boolean controlDown

Whether or not the Control modifier is down on this event.

eventSetIdback to summary
private final int eventSetId
Annotations
@SuppressWarnings:doclint:missing
metaDownback to summary
private final boolean metaDown

Whether or not the Meta modifier is down on this event.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides javafx.scene.input.InputEvent.serialVersionUID.

shiftDownback to summary
private final boolean shiftDown

Whether or not the Shift modifier is down on this event.

TOUCH_MOVEDback to summary
public static final EventType<TouchEvent> TOUCH_MOVED

This event occurs when the touch point is moved.

TOUCH_PRESSEDback to summary
public static final EventType<TouchEvent> TOUCH_PRESSED

This event occurs when the touch point is pressed (touched for the first time).

TOUCH_RELEASEDback to summary
public static final EventType<TouchEvent> TOUCH_RELEASED

This event occurs when the touch point is released.

TOUCH_STATIONARYback to summary
public static final EventType<TouchEvent> TOUCH_STATIONARY

This event occurs when the touch point is pressed and still (doesn't move).

touchPointback to summary
private final TouchPoint touchPoint
Annotations
@SuppressWarnings:doclint:missing
touchPointsback to summary
private final List<TouchPoint> touchPoints
Annotations
@SuppressWarnings:doclint:missing

Constructor Detail

TouchEventback to summary
public TouchEvent(Object source, EventTarget target, EventType<TouchEvent> eventType, TouchPoint touchPoint, List<TouchPoint> touchPoints, int eventSetId, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown)

Constructs new TouchEvent event.

Parameters
source:Object

the source of the event. Can be null.

target:EventTarget

the target of the event. Can be null.

eventType:EventType<TouchEvent>

The type of the event.

touchPoint:TouchPoint

the touch point of this event

touchPoints:List<TouchPoint>

set of touch points for the multi-touch action

eventSetId:int

set id of the multi-touch action

shiftDown:boolean

true if shift modifier was pressed.

controlDown:boolean

true if control modifier was pressed.

altDown:boolean

true if alt modifier was pressed.

metaDown:boolean

true if meta modifier was pressed.

Since
JavaFX 8.0
TouchEventback to summary
public TouchEvent(EventType<TouchEvent> eventType, TouchPoint touchPoint, List<TouchPoint> touchPoints, int eventSetId, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown)

Constructs new TouchEvent event with null source and target.

Parameters
eventType:EventType<TouchEvent>

The type of the event.

touchPoint:TouchPoint

the touch point of this event

touchPoints:List<TouchPoint>

set of touch points for the multi-touch action

eventSetId:int

set id of the multi-touch action

shiftDown:boolean

true if shift modifier was pressed.

controlDown:boolean

true if control modifier was pressed.

altDown:boolean

true if alt modifier was pressed.

metaDown:boolean

true if meta modifier was pressed.

Since
JavaFX 8.0

Method Detail

copyForback to summary
public TouchEvent copyFor(Object newSource, EventTarget newTarget)

Overrides javafx.event.Event.copyFor.

Doc from javafx.event.Event.copyFor.

Creates and returns a copy of this event with the specified event source and target. If the source or target is set to null, it is replaced by the NULL_SOURCE_TARGET value.

Returns:TouchEvent

the event copy with the new source and target

Annotations
@Override
copyForback to summary
public TouchEvent copyFor(Object newSource, EventTarget newTarget, EventType<TouchEvent> type)

Creates a copy of the given event with the given fields substituted.

Parameters
newSource:Object

the new source of the copied event

newTarget:EventTarget

the new target of the copied event

type:EventType<TouchEvent>

the new eventType

Returns:TouchEvent

the event copy with the fields substituted

Since
JavaFX 8.0
getEventSetIdback to summary
public final int getEventSetId()

Gets sequential number of the set of touch events representing the same multi-touch action. For a multi-touch user action, number of touch points may exist; each of them produces a touch event, each of those touch events carry the same list of touch points - and all of them return the same number from this method. Then state of some of the touch points changes and the new set of events has new id. The id is guaranteed to be sequential and unique in scope of one gesture (is reset when all touch points are released).

Returns:int

Sequential id of event set unique in scope of a gesture

getEventTypeback to summary
public EventType<TouchEvent> getEventType()

Overrides javafx.scene.input.InputEvent.getEventType.

Doc from javafx.event.Event.getEventType.

Gets the event type of this event. Objects of the same Event class can have different event types. These event types further specify what kind of event occurred.

Annotations
@Override
getTouchCountback to summary
public int getTouchCount()

Returns number of touch points represented by this touch event set. The returned number matches the size of the touchPoints list.

Returns:int

The number of touch points represented by this touch event set.

getTouchPointback to summary
public TouchPoint getTouchPoint()

Gets the touch point of this event.

Returns:TouchPoint

Touch point of this event

getTouchPointsback to summary
public List<TouchPoint> getTouchPoints()

Gets all the touch points represented by this set of touch events, including the touch point of this event. The list is unmodifiable and is sorted by their IDs, which means it is also sorted by the time they were pressed. To distinguish between touch points belonging to a node and unrelated touch points, TouchPoint's belongsTo method can be used.

Returns:List<TouchPoint>

All current touch points in an unmodifiable list

isAltDownback to summary
public final boolean isAltDown()

Whether or not the Alt modifier is down on this event.

Returns:boolean

true if the Alt modifier is down on this event

isControlDownback to summary
public final boolean isControlDown()

Whether or not the Control modifier is down on this event.

Returns:boolean

true if the Control modifier is down on this event

isMetaDownback to summary
public final boolean isMetaDown()

Whether or not the Meta modifier is down on this event.

Returns:boolean

true if the Meta modifier is down on this event

isShiftDownback to summary
public final boolean isShiftDown()

Whether or not the Shift modifier is down on this event.

Returns:boolean

true if the Shift modifier is down on this event

recomputeToSourceback to summary
private static void recomputeToSource(TouchEvent event, Object oldSource, Object newSource)

Recomputes touch event for the given event source object.

Parameters
event:TouchEvent

Event to modify

oldSource:Object

Source object of the current values

newSource:Object

Source object to compute values for

toStringback to summary
public String toString()

Overrides java.util.EventObject.toString.

Returns a string representation of this TouchEvent object.

Returns:String

a string representation of this TouchEvent object.

Annotations
@Override