Class EventController

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
DropControllerMotion, DropTarget, DropTargetAsync, EventController.EventController$Impl, EventControllerFocus, EventControllerKey, EventControllerLegacy, EventControllerMotion, EventControllerScroll, Gesture, PadController, ShortcutController

@Generated("org.javagi.JavaGI") public abstract class EventController extends GObject

The base class for event controllers.

These are ancillary objects associated to widgets, which react to GdkEvents, and possibly trigger actions as a consequence.

Event controllers are added to a widget with Widget.addController(EventController). It is rarely necessary to explicitly remove a controller with Widget.removeController(EventController).

See the chapter on input handling for an overview of the basic concepts, such as the capture and bubble phases of event propagation.

  • Constructor Details

    • EventController

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

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

    • getType

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

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

      protected EventController 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 GObject
      Returns:
      the instance as if it were its parent type
    • getCurrentEvent

      public @Nullable Event getCurrentEvent()

      Returns the event that is currently being handled by the controller.

      At other times, null is returned.

      Returns:
      the event that is currently handled by this EventController
    • getCurrentEventDevice

      public @Nullable Device getCurrentEventDevice()

      Returns the device of the event that is currently being handled by the controller.

      At other times, null is returned.

      Returns:
      device of the event is currently handled by this EventController
    • getCurrentEventState

      public Set<ModifierType> getCurrentEventState()

      Returns the modifier state of the event that is currently being handled by the controller.

      At other times, 0 is returned.

      Returns:
      modifier state of the event is currently handled by this EventController
    • getCurrentEventTime

      public int getCurrentEventTime()

      Returns the timestamp of the event that is currently being handled by the controller.

      At other times, 0 is returned.

      Returns:
      timestamp of the event is currently handled by this EventController
    • getName

      public @Nullable String getName()
      Gets the name of controller.
      Returns:
      The controller name
    • getPropagationLimit

      public PropagationLimit getPropagationLimit()
      Gets the propagation limit of the event controller.
      Returns:
      the propagation limit
    • getPropagationPhase

      public PropagationPhase getPropagationPhase()
      Gets the propagation phase at which this EventController handles events.
      Returns:
      the propagation phase
    • getWidget

      public @Nullable Widget getWidget()
      Returns the GtkWidget this controller relates to.
      Returns:
      a GtkWidget
    • reset

      public void reset()
      Resets the this EventController to a clean state.
    • setName

      public void setName(@Nullable String name)
      Sets a name on the controller that can be used for debugging.
      Parameters:
      name - a name for this EventController
    • setPropagationLimit

      public void setPropagationLimit(PropagationLimit limit)

      Sets the event propagation limit on the event controller.

      If the limit is set to PropagationLimit.SAME_NATIVE, the controller won't handle events that are targeted at widgets on a different surface, such as popovers.

      Parameters:
      limit - the propagation limit
    • setPropagationPhase

      public void setPropagationPhase(PropagationPhase phase)

      Sets the propagation phase at which a controller handles events.

      If phase is PropagationPhase.NONE, no automatic event handling will be performed, but other additional gesture maintenance will.

      Parameters:
      phase - a propagation phase
    • setStaticName

      public void setStaticName(@Nullable String name)
      Sets a name on the controller that can be used for debugging.
      Parameters:
      name - a name for controller, must be a static string
      Since:
      4.8