Gdk.Event

g Gdk.Event Gdk.Event

Subclasses:

Gdk.ButtonEvent, Gdk.CrossingEvent, Gdk.DNDEvent, Gdk.DeleteEvent, Gdk.FocusEvent, Gdk.GrabBrokenEvent, Gdk.KeyEvent, Gdk.MotionEvent, Gdk.PadEvent, Gdk.ProximityEvent, Gdk.ScrollEvent, Gdk.TouchEvent, Gdk.TouchpadEvent

Methods

get_axes ()

get_axis (axis_use)

get_device ()

get_device_tool ()

get_display ()

get_event_sequence ()

get_event_type ()

get_history ()

get_modifier_state ()

get_pointer_emulated ()

get_position ()

get_seat ()

get_surface ()

get_time ()

ref ()

triggers_context_menu ()

unref ()

Virtual Methods

None

Fields

None

Class Details

class Gdk.Event
Abstract:

Yes

``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.

get_axes()[source]
Returns:

True on success, otherwise False

axes:

the array of values for all axes

Return type:

(bool, axes: [float])

Extracts all axis values from an event.

To find out which axes are used, use [method`Gdk`.DeviceTool.get_axes] on the device tool returned by [method`Gdk`.Event.get_device_tool].

get_axis(axis_use)[source]
Parameters:

axis_use (Gdk.AxisUse) – the axis use to look for

Returns:

True if the specified axis was found, otherwise False

value:

location to store the value found

Return type:

(bool, value: float)

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

To find out which axes are used, use [method`Gdk`.DeviceTool.get_axes] on the device tool returned by [method`Gdk`.Event.get_device_tool].

get_device()[source]
Returns:

a GdkDevice

Return type:

Gdk.Device or None

Returns the device of an event.

get_device_tool()[source]
Returns:

The current device tool

Return type:

Gdk.DeviceTool or None

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 None.

Note: the GdkDeviceTool will be constant during the application lifetime, if settings must be stored persistently across runs, see [method`Gdk`.DeviceTool.get_serial].

get_display()[source]
Returns:

a GdkDisplay

Return type:

Gdk.Display or None

Retrieves the display associated to the self.

get_event_sequence()[source]
Returns:

the event sequence that the event belongs to

Return type:

Gdk.EventSequence

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.

get_event_type()[source]
Returns:

a ``GdkEvent``Type

Return type:

Gdk.EventType

Retrieves the type of the event.

get_history()[source]
Returns:

an array of time and coordinates

Return type:

[Gdk.TimeCoord] or None

Retrieves the history of the device that self 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 self.

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.

get_modifier_state()[source]
Returns:

the modifier state of self

Return type:

Gdk.ModifierType

Returns the modifier state field of an event.

get_pointer_emulated()[source]
Returns:

True if this event is emulated

Return type:

bool

Returns whether this event is an ‘emulated’ pointer event.

Emulated pointer events typically originate from a touch events.

get_position()[source]
Returns:

x:

location to put event surface x coordinate

y:

location to put event surface y coordinate

Return type:

(bool, x: float, y: float)

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

This position is in surface coordinates.

get_seat()[source]
Returns:

a GdkSeat.

Return type:

Gdk.Seat or None

Returns the seat that originated the event.

get_surface()[source]
Returns:

The GdkSurface associated with the event

Return type:

Gdk.Surface or None

Extracts the surface associated with an event.

get_time()[source]
Returns:

timestamp field from self

Return type:

int

Returns the timestamp of self.

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

ref()[source]
Returns:

self

Return type:

Gdk.Event

Increase the ref count of self.

triggers_context_menu()[source]
Returns:

True if the event should trigger a context menu.

Return type:

bool

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

The right mouse button typically triggers context menus.

This function should always be used instead of simply checking for event->button == Gdk.BUTTON_SECONDARY.

unref()[source]

Decrease the ref count of self.

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