:right-sidebar: True Event =================================================================== .. currentmodule:: gi.repository.Gdk .. class:: Event(*args, **kwargs) :no-contents-entry: Subclasses: :class:`~gi.repository.Gdk.ButtonEvent`, :class:`~gi.repository.Gdk.CrossingEvent`, :class:`~gi.repository.Gdk.DNDEvent`, :class:`~gi.repository.Gdk.DeleteEvent`, :class:`~gi.repository.Gdk.FocusEvent`, :class:`~gi.repository.Gdk.GrabBrokenEvent`, :class:`~gi.repository.Gdk.KeyEvent`, :class:`~gi.repository.Gdk.MotionEvent`, :class:`~gi.repository.Gdk.PadEvent`, :class:`~gi.repository.Gdk.ProximityEvent`, :class:`~gi.repository.Gdk.ScrollEvent`, :class:`~gi.repository.Gdk.TouchEvent`, :class:`~gi.repository.Gdk.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. Methods ------- .. rst-class:: interim-class .. class:: Event :no-index: .. method:: get_axes() -> ~typing.Tuple[bool, list[float]] Extracts all axis values from an event. To find out which axes are used, use :obj:`~gi.repository.Gdk.DeviceTool.get_axes` on the device tool returned by :obj:`~gi.repository.Gdk.Event.get_device_tool`\. .. method:: get_axis(axis_use: ~gi.repository.Gdk.AxisUse) -> ~typing.Tuple[bool, float] Extract the axis value for a particular axis use from an event structure. To find out which axes are used, use :obj:`~gi.repository.Gdk.DeviceTool.get_axes` on the device tool returned by :obj:`~gi.repository.Gdk.Event.get_device_tool`\. :param axis_use: the axis use to look for .. method:: get_device() -> ~gi.repository.Gdk.Device | None Returns the device of an event. .. method:: get_device_tool() -> ~gi.repository.Gdk.DeviceTool | 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 :const:`None`. Note: the ``GdkDeviceTool`` will be constant during the application lifetime, if settings must be stored persistently across runs, see :obj:`~gi.repository.Gdk.DeviceTool.get_serial`\. .. method:: get_display() -> ~gi.repository.Gdk.Display | None Retrieves the display associated to the ``event``\. .. method:: get_event_sequence() -> ~gi.repository.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. .. method:: get_event_type() -> ~gi.repository.Gdk.EventType Retrieves the type of the event. .. method:: get_history() -> list[~gi.repository.Gdk.TimeCoord] | None Retrieves the history of the device that ``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. .. method:: get_modifier_state() -> ~gi.repository.Gdk.ModifierType Returns the modifier state field of an event. .. method:: get_pointer_emulated() -> bool Returns whether this event is an 'emulated' pointer event. Emulated pointer events typically originate from a touch events. .. method:: get_position() -> ~typing.Tuple[bool, float, float] Extract the event surface relative x/y coordinates from an event. This position is in `surface coordinates `__\. .. method:: get_seat() -> ~gi.repository.Gdk.Seat | None Returns the seat that originated the event. .. method:: get_surface() -> ~gi.repository.Gdk.Surface | None Extracts the surface associated with an event. .. method:: get_time() -> int Returns the timestamp of ``event``\. Not all events have timestamps. In that case, this function returns :const:`~gi.repository.Gdk.CURRENT_TIME`. .. method:: triggers_context_menu() -> bool 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 .. code-block:: c :dedent: event->button == GDK_BUTTON_SECONDARY