Class GestureSingle

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
DragSource, GestureClick, GestureDrag, GestureLongPress, GestureStylus, GestureSwipe

@Generated("org.javagi.JavaGI") public class GestureSingle extends Gesture

A GtkGesture subclass optimized for singe-touch and mouse gestures.

Under interaction, these gestures stick to the first interacting sequence, which is accessible through getCurrentSequence() while the gesture is being interacted with.

By default gestures react to both GDK_BUTTON_PRIMARY and touch events. setTouchOnly(boolean) can be used to change the touch behavior. Callers may also specify a different mouse button number to interact with through setButton(int), or react to any mouse button by setting it to 0. While the gesture is active, the button being currently pressed can be known through getCurrentButton().

  • Constructor Details

    • GestureSingle

      public GestureSingle(MemorySegment address)
      Create a GestureSingle instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • GestureSingle

      public GestureSingle()
      Create a new GestureSingle.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the GestureSingle class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected GestureSingle asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Gesture
      Returns:
      the instance as if it were its parent type
    • getButton

      public int getButton()

      Returns the button number this GestureSingle listens for.

      If this is 0, the gesture reacts to any button press.

      Returns:
      The button number, or 0 for any button
    • getCurrentButton

      public int getCurrentButton()
      Returns the button number currently interacting with gesture, or 0 if there is none.
      Returns:
      The current button number
    • getCurrentSequence

      public @Nullable EventSequence getCurrentSequence()

      Returns the event sequence currently interacting with gesture.

      This is only meaningful if Gesture.isActive() returns true.

      Returns:
      the current sequence
    • getExclusive

      public boolean getExclusive()

      Gets whether a gesture is exclusive.

      For more information, see setExclusive(boolean).

      Returns:
      Whether the gesture is exclusive
    • getTouchOnly

      public boolean getTouchOnly()
      Returns true if the gesture is only triggered by touch events.
      Returns:
      true if the gesture only handles touch events
    • setButton

      public void setButton(int button)

      Sets the button number this GestureSingle listens to.

      If non-0, every button press from a different button number will be ignored. Touch events implicitly match with button 1.

      Parameters:
      button - button number to listen to, or 0 for any button
    • setExclusive

      public void setExclusive(boolean exclusive)

      Sets whether this GestureSingle is exclusive.

      An exclusive gesture will only handle pointer and "pointer emulated" touch events, so at any given time, there is only one sequence able to interact with those.

      Parameters:
      exclusive - true to make this GestureSingle exclusive
    • setTouchOnly

      public void setTouchOnly(boolean touchOnly)

      Sets whether to handle only touch events.

      If touchOnly is true, this GestureSingle will only handle events of type EventType.TOUCH_BEGIN, EventType.TOUCH_UPDATE or EventType.TOUCH_END. If false, mouse events will be handled too.

      Parameters:
      touchOnly - whether this GestureSingle handles only touch events
    • builder

      public static GestureSingle.Builder<? extends GestureSingle.Builder> builder()
      A GestureSingle.Builder object constructs a GestureSingle with the specified properties. Use the various set...() methods to set properties, and finish construction with GestureSingle.Builder.build().
      Returns:
      the builder object