Class Event

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
ButtonEvent, CrossingEvent, DeleteEvent, DNDEvent, Event.Event$Impl, FocusEvent, GrabBrokenEvent, KeyEvent, MotionEvent, PadEvent, ProximityEvent, ScrollEvent, TouchEvent, TouchpadEvent

@Generated("org.javagi.JavaGI") public abstract class Event extends TypeInstance

Represents windowing system events.

In GTK applications the events are handled automatically by toplevel widgets and passed on to the event controllers of appropriate widgets, so using GdkEvent and its related API is rarely needed.

GdkEvent structs are immutable.

  • Constructor Details

    • Event

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

    • getType

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

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

      protected Event 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.
      Returns:
      the instance as if it were its parent type
    • eventsGetAngle

      public boolean eventsGetAngle(Event event2, Out<Double> angle)

      Returns the relative angle from this Event to event2.

      The relative angle is the angle between the X axis and the line through both events' positions. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.

      This assumes that both events have X/Y information. If not, this function returns false.

      Parameters:
      event2 - second GdkEvent
      angle - return location for the relative angle between both events
      Returns:
      true if the angle could be calculated.
    • eventsGetCenter

      public boolean eventsGetCenter(Event event2, Out<Double> x, Out<Double> y)

      Returns the point halfway between the events' positions.

      This assumes that both events have X/Y information. If not, this function returns false.

      Parameters:
      event2 - second GdkEvent
      x - return location for the X coordinate of the center
      y - return location for the Y coordinate of the center
      Returns:
      true if the center could be calculated.
    • eventsGetDistance

      public boolean eventsGetDistance(Event event2, Out<Double> distance)

      Returns the distance between the event locations.

      This assumes that both events have X/Y information. If not, this function returns false.

      Parameters:
      event2 - second GdkEvent
      distance - return location for the distance
      Returns:
      true if the distance could be calculated.
    • getAxes

      public boolean getAxes(@Nullable Out<double[]> axes)

      Extracts all axis values from an event.

      To find out which axes are used, use DeviceTool.getAxes() on the device tool returned by getDeviceTool().

      Parameters:
      axes - the array of values for all axes
      Returns:
      true on success, otherwise false
    • getAxis

      public boolean getAxis(AxisUse axisUse, Out<Double> value)

      Extract the axis value for a particular axis use from an event structure.

      To find out which axes are used, use DeviceTool.getAxes() on the device tool returned by getDeviceTool().

      Parameters:
      axisUse - the axis use to look for
      value - location to store the value found
      Returns:
      true if the specified axis was found, otherwise false
    • getDevice

      public @Nullable Device getDevice()
      Returns the device of an event.
      Returns:
      a GdkDevice
    • getDeviceTool

      public @Nullable DeviceTool getDeviceTool()

      Returns a GdkDeviceTool representing the tool that caused the event.

      If the was not generated by a device that supports different tools (such as a tablet), this function will return null.

      Note: the GdkDeviceTool will be constant during the application lifetime, if settings must be stored persistently across runs, see DeviceTool.getSerial().

      Returns:
      The current device tool
    • getDisplay

      public @Nullable Display getDisplay()
      Retrieves the display associated to the event.
      Returns:
      a GdkDisplay
    • getEventSequence

      public EventSequence getEventSequence()

      Returns the event sequence to which the event belongs.

      Related touch events are connected in a sequence. Other events typically don't have event sequence information.

      Returns:
      the event sequence that the event belongs to
    • getEventType

      public EventType getEventType()
      Retrieves the type of the event.
      Returns:
      a GdkEventType
    • getHistory

      public @Nullable TimeCoord @Nullable [] getHistory()

      Retrieves the history of the device that this Event is for, as a list of time and coordinates.

      The history includes positions that are not delivered as separate events to the application because they occurred in the same frame as event.

      Note that only motion and scroll events record history, and motion events do it only if one of the mouse buttons is down, or the device has a tool.

      Returns:
      an array of time and coordinates
    • getModifierState

      public Set<ModifierType> getModifierState()
      Returns the modifier state field of an event.
      Returns:
      the modifier state of this Event
    • getPointerEmulated

      public boolean getPointerEmulated()

      Returns whether this event is an 'emulated' pointer event.

      Emulated pointer events typically originate from a touch events.

      Returns:
      true if this event is emulated
    • getPosition

      public boolean getPosition(Out<Double> x, Out<Double> y)

      Extract the event surface relative x/y coordinates from an event.

      This position is in surface coordinates.

      Parameters:
      x - location to put event surface x coordinate
      y - location to put event surface y coordinate
      Returns:
      whether the positions were set
    • getSeat

      public @Nullable Seat getSeat()
      Returns the seat that originated the event.
      Returns:
      a GdkSeat.
    • getSurface

      public @Nullable Surface getSurface()
      Extracts the surface associated with an event.
      Returns:
      The GdkSurface associated with the event
    • getTime

      public int getTime()

      Returns the timestamp of event.

      Not all events have timestamps. In that case, this function returns GDK_CURRENT_TIME.

      Returns:
      timestamp field from this Event
    • ref

      public Event ref()
      Increase the ref count of event.
      Returns:
      this Event
    • triggersContextMenu

      public boolean triggersContextMenu()

      Returns whether a GdkEvent should trigger a context menu, according to platform conventions.

      The right mouse button typically triggers context menus. On macOS, Control+left mouse button also triggers.

      This function should always be used instead of simply checking for

      event->button == GDK_BUTTON_SECONDARY
      
      Returns:
      true if the event should trigger a context menu.
    • unref

      public void unref()

      Decrease the ref count of event.

      If the last reference is dropped, the structure is freed.