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
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe Event$Impl type represents a native instance of the abstract Event class. -
Constructor Summary
ConstructorsConstructorDescriptionEvent(MemorySegment address) Create a Event proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected EventasParent()Returns this instance as if it were its parent type.booleaneventsGetAngle(Event event2, Out<Double> angle) Returns the relative angle from this Event toevent2.booleanReturns the point halfway between the events' positions.booleaneventsGetDistance(Event event2, Out<Double> distance) Returns the distance between the event locations.booleanExtracts all axis values from an event.booleanExtract the axis value for a particular axis use from an event structure.@Nullable DeviceReturns the device of an event.@Nullable DeviceToolReturns aGdkDeviceToolrepresenting the tool that caused the event.@Nullable DisplayRetrieves the display associated to theevent.Returns the event sequence to which the event belongs.Retrieves the type of the event.@Nullable TimeCoord @Nullable []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.booleanReturns whether this event is an 'emulated' pointer event.booleangetPosition(Out<Double> x, Out<Double> y) Extract the event surface relative x/y coordinates from an event.@Nullable SeatgetSeat()Returns the seat that originated the event.@Nullable SurfaceExtracts the surface associated with an event.intgetTime()Returns the timestamp ofevent.static @Nullable TypegetType()Get the GType of the Event classref()Increase the ref count ofevent.booleanReturns whether aGdkEventshould trigger a context menu, according to platform conventions.voidunref()Decrease the ref count ofevent.Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getMemoryLayout, getPrivate, readGClass, writeGClassMethods inherited from class org.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 Javasuperkeyword, 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- secondGdkEventangle- return location for the relative angle between both events- Returns:
trueif 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- secondGdkEventx- return location for the X coordinate of the centery- return location for the Y coordinate of the center- Returns:
trueif 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- secondGdkEventdistance- return location for the distance- Returns:
trueif 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:
trueon 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:
trueif the specified axis was found, otherwisefalse
-
getDevice
-
getDeviceTool
Returns aGdkDeviceToolrepresenting 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
GdkDeviceToolwill 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 theevent.- 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
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:
trueif 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
GdkSurfaceassociated with the event
-
getTime
public int getTime()Returns the timestamp ofevent.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 aGdkEventshould 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:
trueif the event should trigger a context menu.
-
unref
public void unref()Decrease the ref count ofevent.If the last reference is dropped, the structure is freed.
-