Gtk.EventControllerScroll

g GObject.Object GObject.Object Gtk.EventController Gtk.EventController GObject.Object->Gtk.EventController Gtk.EventControllerScroll Gtk.EventControllerScroll Gtk.EventController->Gtk.EventControllerScroll

Subclasses:

None

Methods

Inherited:

Gtk.EventController (13), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (flags)

get_flags ()

get_unit ()

set_flags (flags)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Inherited:

Gtk.EventController (4)

Name

Type

Flags

Short Description

flags

Gtk.EventControllerScrollFlags

r/w/en

Signals

Inherited:

GObject.Object (1)

Name

Short Description

decelerate

Emitted after scroll is finished if the Gtk.EventControllerScrollFlags.KINETIC flag is set.

scroll

Signals that the widget should scroll by the amount specified by dx and dy.

scroll-begin

Signals that a new scrolling operation has begun.

scroll-end

Signals that a scrolling operation has finished.

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.EventControllerScroll(**kwargs)
Bases:

Gtk.EventController

Abstract:

No

Structure:

Gtk.EventControllerScrollClass

GtkEventControllerScroll is an event controller that handles scroll events.

It is capable of handling both discrete and continuous scroll events from mice or touchpads, abstracting them both with the [signal`Gtk`.EventControllerScroll::scroll] signal. Deltas in the discrete case are multiples of 1.

In the case of continuous scroll events, GtkEventControllerScroll encloses all [signal`Gtk`.EventControllerScroll::scroll] emissions between two [signal`Gtk`.EventControllerScroll::scroll-begin] and [signal`Gtk`.EventControllerScroll::scroll-end] signals.

The behavior of the event controller can be modified by the flags given at creation time, or modified at a later point through [method`Gtk`.EventControllerScroll.set_flags] (e.g. because the scrolling conditions of the widget changed).

The controller can be set up to emit motion for either/both vertical and horizontal scroll events through Gtk.EventControllerScrollFlags.VERTICAL, Gtk.EventControllerScrollFlags.HORIZONTAL and Gtk.EventControllerScrollFlags.BOTH_AXES. If any axis is disabled, the respective [signal`Gtk`.EventControllerScroll::scroll] delta will be 0. Vertical scroll events will be translated to horizontal motion for the devices incapable of horizontal scrolling.

The event controller can also be forced to emit discrete events on all devices through Gtk.EventControllerScrollFlags.DISCRETE. This can be used to implement discrete actions triggered through scroll events (e.g. switching across combobox options).

The Gtk.EventControllerScrollFlags.KINETIC flag toggles the emission of the [signal`Gtk`.EventControllerScroll::decelerate] signal, emitted at the end of scrolling with two X/Y velocity arguments that are consistent with the motion that was received.

classmethod new(flags)[source]
Parameters:

flags (Gtk.EventControllerScrollFlags) – flags affecting the controller behavior

Returns:

a new GtkEventControllerScroll

Return type:

Gtk.EventController

Creates a new event controller that will handle scroll events.

get_flags()[source]
Returns:

the controller flags.

Return type:

Gtk.EventControllerScrollFlags

Gets the flags conditioning the scroll controller behavior.

get_unit()[source]
Returns:

the scroll unit.

Return type:

Gdk.ScrollUnit

Gets the scroll unit of the last [signal`Gtk`.EventControllerScroll::scroll] signal received.

Always returns Gdk.ScrollUnit.WHEEL if the Gtk.EventControllerScrollFlags.DISCRETE flag is set.

New in version 4.8.

set_flags(flags)[source]
Parameters:

flags (Gtk.EventControllerScrollFlags) – flags affecting the controller behavior

Sets the flags conditioning scroll controller behavior.

Signal Details

Gtk.EventControllerScroll.signals.decelerate(event_controller_scroll, vel_x, vel_y)
Signal Name:

decelerate

Flags:

RUN_FIRST

Parameters:

Emitted after scroll is finished if the Gtk.EventControllerScrollFlags.KINETIC flag is set.

vel_x and vel_y express the initial velocity that was imprinted by the scroll events. vel_x and vel_y are expressed in pixels/ms.

Gtk.EventControllerScroll.signals.scroll(event_controller_scroll, dx, dy)
Signal Name:

scroll

Flags:

RUN_LAST

Parameters:
Returns:

True if the scroll event was handled, False otherwise.

Return type:

bool

Signals that the widget should scroll by the amount specified by dx and dy.

For the representation unit of the deltas, see [method`Gtk`.EventControllerScroll.get_unit].

Gtk.EventControllerScroll.signals.scroll_begin(event_controller_scroll)
Signal Name:

scroll-begin

Flags:

RUN_FIRST

Parameters:

event_controller_scroll (Gtk.EventControllerScroll) – The object which received the signal

Signals that a new scrolling operation has begun.

It will only be emitted on devices capable of it.

Gtk.EventControllerScroll.signals.scroll_end(event_controller_scroll)
Signal Name:

scroll-end

Flags:

RUN_FIRST

Parameters:

event_controller_scroll (Gtk.EventControllerScroll) – The object which received the signal

Signals that a scrolling operation has finished.

It will only be emitted on devices capable of it.

Property Details

Gtk.EventControllerScroll.props.flags
Name:

flags

Type:

Gtk.EventControllerScrollFlags

Default Value:

Gtk.EventControllerScrollFlags.NONE

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The flags affecting event controller behavior.