Skip to content

Gtk.GestureStylus

class — extends GestureSingle

Recognizes tablet stylus input.

The provided signals just relay the basic information of the stylus events.

Constructors

new

@classmethod
def new(cls) -> Gesture

Creates a new GtkGestureStylus.

Methods

get_axes

def get_axes(self, axes: list[Gdk.AxisUse | int]) -> tuple[bool, list[float]]

Returns the current values for the requested axes.

This function must be called from the handler of one of the GestureStylus.down, GestureStylus.motion, GestureStylus.up or GestureStylus.proximity signals.

Parameters:

get_axis

def get_axis(self, axis: Gdk.AxisUse | int) -> tuple[bool, float]

Returns the current value for the requested axis.

This function must be called from the handler of one of the GestureStylus.down, GestureStylus.motion, GestureStylus.up or GestureStylus.proximity signals.

Parameters:

  • axis — requested device axis

get_backlog

def get_backlog(self) -> tuple[bool, list[Gdk.TimeCoord]]

Returns the accumulated backlog of tracking information.

By default, GTK will limit rate of input events. On stylus input where accuracy of strokes is paramount, this function returns the accumulated coordinate/timing state before the emission of the current [Gtk.GestureStylus::motion] signal.

This function may only be called within a GestureStylus.motion signal handler, the state given in this signal and obtainable through GestureStylus.get_axis express the latest (most up-to-date) state in motion history.

The backlog is provided in chronological order.

get_device_tool

def get_device_tool(self) -> Gdk.DeviceTool | None

Returns the GdkDeviceTool currently driving input through this gesture.

This function must be called from the handler of one of the GestureStylus.down, GestureStylus.motion, GestureStylus.up or GestureStylus.proximity signals.

get_stylus_only

def get_stylus_only(self) -> bool

Checks whether the gesture is for styluses only.

Stylus-only gestures will signal events exclusively from stylus input devices.

set_stylus_only

def set_stylus_only(self, stylus_only: bool) -> None

Sets the state of stylus-only

If true, the gesture will exclusively handle events from stylus input devices, otherwise it'll handle events from any pointing device.

Parameters:

  • stylus_only — whether the gesture is used exclusively for stylus events

Properties

stylus_only

stylus_only: bool  # read/write

If this gesture should exclusively react to stylus input devices.

Signals

down

def on_down(self, x: float, y: float) -> None: ...

Emitted when the stylus touches the device.

motion

def on_motion(self, x: float, y: float) -> None: ...

Emitted when the stylus moves while touching the device.

proximity

def on_proximity(self, x: float, y: float) -> None: ...

Emitted when the stylus is in proximity of the device.

up

def on_up(self, x: float, y: float) -> None: ...

Emitted when the stylus no longer touches the device.