:right-sidebar: True GestureSingle =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: GestureSingle(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Gesture`, :class:`~gi.repository.Gtk.EventController`, :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gtk.DragSource`, :class:`~gi.repository.Gtk.GestureClick`, :class:`~gi.repository.Gtk.GestureDrag`, :class:`~gi.repository.Gtk.GestureLongPress`, :class:`~gi.repository.Gtk.GestureStylus`, :class:`~gi.repository.Gtk.GestureSwipe` ``GtkGestureSingle`` is a ``GtkGestures`` subclass optimized for singe-touch and mouse gestures. Under interaction, these gestures stick to the first interacting sequence, which is accessible through :obj:`~gi.repository.Gtk.GestureSingle.get_current_sequence` while the gesture is being interacted with. By default gestures react to both ``%GDK_BUTTON_PRIMARY`` and touch events. :obj:`~gi.repository.Gtk.GestureSingle.set_touch_only` can be used to change the touch behavior. Callers may also specify a different mouse button number to interact with through :obj:`~gi.repository.Gtk.GestureSingle.set_button`, or react to any mouse button by setting it to 0. While the gesture is active, the button being currently pressed can be known through :obj:`~gi.repository.Gtk.GestureSingle.get_current_button`. Methods ------- .. rst-class:: interim-class .. class:: GestureSingle :no-index: .. method:: get_button() -> int Returns the button number ``gesture`` listens for. If this is 0, the gesture reacts to any button press. .. method:: get_current_button() -> int Returns the button number currently interacting with ``gesture``, or 0 if there is none. .. method:: get_current_sequence() -> ~gi.repository.Gdk.EventSequence | None Returns the event sequence currently interacting with ``gesture``. This is only meaningful if :obj:`~gi.repository.Gtk.Gesture.is_active` returns :const:`True`. .. method:: get_exclusive() -> bool Gets whether a gesture is exclusive. For more information, see :obj:`~gi.repository.Gtk.GestureSingle.set_exclusive`. .. method:: get_touch_only() -> bool Returns :const:`True` if the gesture is only triggered by touch events. .. method:: set_button(button: int) -> None Sets the button number ``gesture`` listens to. If non-0, every button press from a different button number will be ignored. Touch events implicitly match with button 1. :param button: button number to listen to, or 0 for any button .. method:: set_exclusive(exclusive: bool) -> None Sets whether ``gesture`` is exclusive. An exclusive gesture will only handle pointer and "pointer emulated" touch events, so at any given time, there is only one sequence able to interact with those. :param exclusive: :const:`True` to make ``gesture`` exclusive .. method:: set_touch_only(touch_only: bool) -> None Sets whether to handle only touch events. If ``touch_only`` is :const:`True`, ``gesture`` will only handle events of type ``%GDK_TOUCH_BEGIN``, ``%GDK_TOUCH_UPDATE`` or ``%GDK_TOUCH_END``. If :const:`False`, mouse events will be handled too. :param touch_only: whether ``gesture`` handles only touch events Properties ---------- .. rst-class:: interim-class .. class:: GestureSingle :no-index: .. attribute:: props.button :type: int Mouse button number to listen to, or 0 to listen for any button. .. attribute:: props.exclusive :type: bool Whether the gesture is exclusive. Exclusive gestures only listen to pointer and pointer emulated events. .. attribute:: props.touch_only :type: bool Whether the gesture handles only touch events.