Class TapHoldEvent


public class TapHoldEvent extends TouchEvent
Represents a tap-and-hold gesture event that occurs when a user touches and maintains contact on a touch-enabled device.

This event is fired when the user touches a point on a touch surface and holds their finger in place for an extended period. It extends TouchEvent as it is part of the touch interaction framework and is dispatched to registered TouchListener instances for processing. This event is commonly used to trigger context menus, tooltips, or alternative actions on touch-enabled interfaces.

Features:

  • Detects prolonged touch gestures on touch devices
  • Part of the touch event framework
  • Equivalent to right-click or long-press actions
  • Integrates with the touch event listener pattern

Usage:


 // Create a tap hold event
 TapHoldEvent event = new TapHoldEvent();

 // Dispatch to a listener to handle tap-and-hold gestures
 event.dispatchTo(myTouchListener);

 // Common use case: show context menu
 public void onEvent(TapHoldEvent event) {
     System.out.println("Tap and hold detected");
     showContextMenu();
 }
 
Since:
2016
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • TapHoldEvent

      public TapHoldEvent()
  • Method Details

    • dispatchTo

      public void dispatchTo(TouchListener listener)
      Dispatches this event to the specified listener for processing.

      This method invokes the listener's onEvent method with this event instance, allowing the listener to handle the tap-and-hold gesture, such as displaying context menus or triggering alternative actions.

      Specified by:
      dispatchTo in class Event<TouchListener>
      Parameters:
      listener - the listener to which this event should be dispatched