Class TouchEvent
- Direct Known Subclasses:
ScrollStartEvent,ScrollStopEvent,SwipeEvent,SwipeLeftEvent,SwipeRightEvent,TapEvent,TapHoldEvent,TouchCancelEvent,TouchEndEvent,TouchMoveEvent,TouchStartEvent
This class serves as the foundation for specific touch event types, providing a common
framework for touch interactions on mobile and touch-enabled devices. All touch events
extend this class and are dispatched to registered TouchListener instances.
Touch events encompass both native browser touch events (touchstart, touchmove, touchend,
touchcancel) and higher-level gestures such as taps, swipes, and scroll actions.
Features:
- Provides coordinate and touch identity tracking for native touch events
- Captures the number of active touch points
- Serves as a base for both native touch and gesture event types
- Integrates with the TouchListener interface
- Since:
- 2016
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a new TouchEvent with no coordinate data.protectedTouchEvent(int clientX, int clientY, int identifier, int touchCount) Constructs a new TouchEvent with the specified touch data. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the X coordinate of the first changed touch relative to the client viewport.intReturns the Y coordinate of the first changed touch relative to the client viewport.intReturns the unique identifier of the touch point.intReturns the number of currently active touch points on the touch surface.Methods inherited from class com.oorian.messaging.events.client.ClientEvent
getSource, getTarget, setSource, setTargetMethods inherited from class com.oorian.messaging.events.Event
bubbles, dispatchTo
-
Constructor Details
-
TouchEvent
protected TouchEvent()Constructs a new TouchEvent with no coordinate data.Used by gesture event subclasses (TapEvent, SwipeEvent, etc.) that do not carry individual touch coordinate information.
-
TouchEvent
protected TouchEvent(int clientX, int clientY, int identifier, int touchCount) Constructs a new TouchEvent with the specified touch data.Used by native touch event subclasses (TouchStartEvent, TouchMoveEvent, etc.) that carry coordinate and touch identity information from the browser.
- Parameters:
clientX- the X coordinate of the first changed touch relative to the client viewportclientY- the Y coordinate of the first changed touch relative to the client viewportidentifier- the unique identifier of the touch pointtouchCount- the number of currently active touch points
-
-
Method Details
-
getClientX
public int getClientX()Returns the X coordinate of the first changed touch relative to the client viewport.- Returns:
- the X coordinate of the touch event
-
getClientY
public int getClientY()Returns the Y coordinate of the first changed touch relative to the client viewport.- Returns:
- the Y coordinate of the touch event
-
getIdentifier
public int getIdentifier()Returns the unique identifier of the touch point.Each touch point is assigned a unique identifier that persists for the duration of the touch interaction, allowing tracking of individual fingers across touchstart, touchmove, and touchend events.
- Returns:
- the touch point identifier
-
getTouchCount
public int getTouchCount()Returns the number of currently active touch points on the touch surface.- Returns:
- the number of active touches
-