Interface TouchListener
- All Superinterfaces:
ClientEventListener,EventListener
Implementations of this interface receive notifications for various touch interactions including taps, tap-and-hold gestures, swipes (general and directional), and scroll lifecycle events. This interface provides a complete set of callbacks for all standard touch gestures on mobile and touch-enabled devices, following the observer pattern.
Features:
- Handles all standard touch event types
- Provides fine-grained control over touch interactions
- Extends the client event listener framework
- Supports the complete touch gesture lifecycle
Usage:
public class TouchInteractivePanel implements TouchListener {
{@literal @}Override
public void onEvent(TapEvent event) {
System.out.println("Panel tapped");
handleTap();
}
{@literal @}Override
public void onEvent(TapHoldEvent event) {
System.out.println("Tap and hold detected");
showContextMenu();
}
{@literal @}Override
public void onEvent(SwipeEvent event) {
System.out.println("General swipe detected");
}
{@literal @}Override
public void onEvent(SwipeLeftEvent event) {
System.out.println("Swiped left - next item");
navigateNext();
}
{@literal @}Override
public void onEvent(SwipeRightEvent event) {
System.out.println("Swiped right - previous item");
navigatePrevious();
}
{@literal @}Override
public void onEvent(ScrollStartEvent event) {
System.out.println("Scroll started");
disableOtherGestures();
}
{@literal @}Override
public void onEvent(ScrollStopEvent event) {
System.out.println("Scroll stopped");
enableOtherGestures();
}
}
- Since:
- 2007
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidonEvent(ScrollStartEvent event) Invoked when a scroll start event occurs.voidonEvent(ScrollStopEvent event) Invoked when a scroll stop event occurs.voidonEvent(SwipeEvent event) Invoked when a general swipe event occurs.voidonEvent(SwipeLeftEvent event) Invoked when a leftward swipe event occurs.voidonEvent(SwipeRightEvent event) Invoked when a rightward swipe event occurs.voidInvoked when a tap event occurs.voidonEvent(TapHoldEvent event) Invoked when a tap-and-hold event occurs.voidonEvent(TouchCancelEvent event) Invoked when a native touchcancel event occurs.voidonEvent(TouchEndEvent event) Invoked when a native touchend event occurs.voidonEvent(TouchMoveEvent event) Invoked when a native touchmove event occurs.voidonEvent(TouchStartEvent event) Invoked when a native touchstart event occurs.
-
Method Details
-
onEvent
Invoked when a general swipe event occurs.This method is called when the user performs a swipe gesture in any direction. This serves as a catch-all for swipe gestures that may not have a specific directional handler.
- Parameters:
event- the swipe event containing gesture information
-
onEvent
Invoked when a leftward swipe event occurs.This method is called when the user performs a swipe gesture from right to left, commonly used for navigation to the next item or dismissing content.
- Parameters:
event- the swipe left event containing gesture information
-
onEvent
Invoked when a rightward swipe event occurs.This method is called when the user performs a swipe gesture from left to right, commonly used for navigation to the previous item or revealing content.
- Parameters:
event- the swipe right event containing gesture information
-
onEvent
Invoked when a scroll start event occurs.This method is called when the user begins a scrolling gesture on a touch-enabled device, useful for disabling other gestures or showing scroll indicators.
- Parameters:
event- the scroll start event indicating the beginning of a scroll gesture
-
onEvent
Invoked when a scroll stop event occurs.This method is called when the user ends a scrolling gesture on a touch-enabled device, useful for re-enabling other gestures or saving scroll position.
- Parameters:
event- the scroll stop event indicating the end of a scroll gesture
-
onEvent
Invoked when a tap event occurs.This method is called when the user performs a quick tap gesture on a touch surface, equivalent to a click on traditional pointer devices.
- Parameters:
event- the tap event containing gesture information
-
onEvent
Invoked when a tap-and-hold event occurs.This method is called when the user touches and holds on a touch surface for an extended period, commonly used to display context menus or tooltips.
- Parameters:
event- the tap hold event containing gesture information
-
onEvent
Invoked when a native touchstart event occurs.This method is called when one or more touch points are placed on the touch surface.
- Parameters:
event- the touch start event containing touch coordinates and identity
-
onEvent
Invoked when a native touchmove event occurs.This method is called when one or more touch points are moved along the touch surface.
- Parameters:
event- the touch move event containing updated touch coordinates
-
onEvent
Invoked when a native touchend event occurs.This method is called when one or more touch points are removed from the touch surface.
- Parameters:
event- the touch end event containing final touch coordinates
-
onEvent
Invoked when a native touchcancel event occurs.This method is called when a touch interaction is interrupted by the system.
- Parameters:
event- the touch cancel event containing touch data at the time of cancellation
-