Class Event
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
ButtonEvent
,CrossingEvent
,DeleteEvent
,DNDEvent
,Event.EventImpl
,FocusEvent
,GrabBrokenEvent
,KeyEvent
,MotionEvent
,PadEvent
,ProximityEvent
,ScrollEvent
,TouchEvent
,TouchpadEvent
GdkEvent
s are immutable data structures, created by GDK to
represent 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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The EventImpl type represents a native instance of the abstract Event class. -
Constructor Summary
ConstructorDescriptionEvent
(MemorySegment address) Create a Event proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Event
asParent()
Returns this instance as if it were its parent type.boolean
eventsGetAngle
(Event event2, Out<Double> angle) Returns the relative angle from this Event toevent2
.boolean
Returns the point halfway between the events' positions.boolean
eventsGetDistance
(Event event2, Out<Double> distance) Returns the distance between the event locations.boolean
Extracts all axis values from an event.boolean
Extract the axis value for a particular axis use from an event structure.Returns the device of an event.Returns aGdkDeviceTool
representing the tool that caused the event.Retrieves the display associated to the this Event.Returns the event sequence to which the event belongs.Retrieves the type of the event.Retrieves the history of the device that this Event is for, as a list of time and coordinates.Returns the modifier state field of an event.boolean
Returns whether this event is an 'emulated' pointer event.boolean
getPosition
(Out<Double> x, Out<Double> y) Extract the event surface relative x/y coordinates from an event.getSeat()
Returns the seat that originated the event.Extracts the surface associated with an event.int
getTime()
Returns the timestamp of this Event.static Type
getType()
Get the GType of the Event classref()
Increase the ref count of this Event.boolean
Returns whether aGdkEvent
should trigger a context menu, according to platform conventions.void
unref()
Decrease the ref count of this Event.Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getMemoryLayout, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Event
Create a Event proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
eventsGetAngle
Returns the relative angle from this Event toevent2
.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
- secondGdkEvent
angle
- return location for the relative angle between both events- Returns:
true
if the angle could be calculated.
-
eventsGetCenter
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
- secondGdkEvent
x
- return location for the X coordinate of the centery
- return location for the Y coordinate of the center- Returns:
true
if the center could be calculated.
-
eventsGetDistance
Returns the distance between the event locations.This assumes that both events have X/Y information. If not, this function returns
false
.- Parameters:
event2
- secondGdkEvent
distance
- return location for the distance- Returns:
true
if the distance could be calculated.
-
getAxes
Extracts all axis values from an event.To find out which axes are used, use
DeviceTool.getAxes()
on the device tool returned bygetDeviceTool()
.- Parameters:
axes
- the array of values for all axes- Returns:
true
on success, otherwisefalse
-
getAxis
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 bygetDeviceTool()
.- Parameters:
axisUse
- the axis use to look forvalue
- location to store the value found- Returns:
true
if the specified axis was found, otherwisefalse
-
getDevice
-
getDeviceTool
Returns aGdkDeviceTool
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, seeDeviceTool.getSerial()
.- Returns:
- The current device tool
-
getDisplay
Retrieves the display associated to the this Event.- Returns:
- a
GdkDisplay
-
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
-
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 this 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
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
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 coordinatey
- location to put event surface y coordinate- Returns:
- whether the positions were set
-
getSeat
-
getSurface
Extracts the surface associated with an event.- Returns:
- The
GdkSurface
associated with the event
-
getTime
public int getTime()Returns the timestamp of this Event.Not all events have timestamps. In that case, this function returns
GDK_CURRENT_TIME
.- Returns:
- timestamp field from this Event
-
ref
-
triggersContextMenu
public boolean triggersContextMenu()Returns whether aGdkEvent
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 this Event.If the last reference is dropped, the structure is freed.
-