CtkEventControllerScroll

CtkEventControllerScroll — Event controller for scroll events

Functions

Properties

Signals

void decelerate Run First
void scroll Run First
void scroll-begin Run First
void scroll-end Run First

Types and Values

Object Hierarchy

    GObject
    ╰── CtkEventController
        ╰── CtkEventControllerScroll

Includes

#include <ctk/ctk.h>

Description

CtkEventControllerScroll is an event controller meant to handle scroll events from mice and touchpads. It is capable of handling both discrete and continuous scroll events, abstracting them both on the “scroll” signal (deltas in the discrete case are multiples of 1).

In the case of continuous scroll events, CtkEventControllerScroll encloses all “scroll” events between two “scroll-begin” and “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 ctk_event_controller_scroll_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 CTK_EVENT_CONTROLLER_SCROLL_VERTICAL, CTK_EVENT_CONTROLLER_SCROLL_HORIZONTAL and CTK_EVENT_CONTROLLER_SCROLL_BOTH. If any axis is disabled, the respective “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 CTK_EVENT_CONTROLLER_SCROLL_DISCRETE. This can be used to implement discrete actions triggered through scroll events (e.g. switching across combobox options).

The CTK_EVENT_CONTROLLER_SCROLL_KINETIC flag toggles the emission of the “decelerate” signal, emitted at the end of scrolling with two X/Y velocity arguments that are consistent with the motion that was received.

This object was added in 3.24.

Functions

ctk_event_controller_scroll_new ()

CtkEventController *
ctk_event_controller_scroll_new (CtkWidget *widget,
                                 CtkEventControllerScrollFlags flags);

Creates a new event controller that will handle scroll events for the given widget .

Parameters

widget

a CtkWidget

 

flags

behavior flags

 

Returns

a new CtkEventControllerScroll

Since: 3.24


ctk_event_controller_scroll_set_flags ()

void
ctk_event_controller_scroll_set_flags (CtkEventControllerScroll *scroll,
                                       CtkEventControllerScrollFlags flags);

Sets the flags conditioning scroll controller behavior.

Parameters

scroll

a CtkEventControllerScroll

 

flags

behavior flags

 

Since: 3.24


ctk_event_controller_scroll_get_flags ()

CtkEventControllerScrollFlags
ctk_event_controller_scroll_get_flags (CtkEventControllerScroll *scroll);

Gets the flags conditioning the scroll controller behavior.

Parameters

Returns

the controller flags.

Since: 3.24

Types and Values

CtkEventControllerScroll

typedef struct _CtkEventControllerScroll CtkEventControllerScroll;

enum CtkEventControllerScrollFlags

Describes the behavior of a CtkEventControllerScroll.

Members

CTK_EVENT_CONTROLLER_SCROLL_NONE

Don't emit scroll.

 

CTK_EVENT_CONTROLLER_SCROLL_VERTICAL

Emit scroll with vertical deltas.

 

CTK_EVENT_CONTROLLER_SCROLL_HORIZONTAL

Emit scroll with horizontal deltas.

 

CTK_EVENT_CONTROLLER_SCROLL_DISCRETE

Only emit deltas that are multiples of 1.

 

CTK_EVENT_CONTROLLER_SCROLL_KINETIC

Emit “decelerate” after continuous scroll finishes.

 

CTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES

Emit scroll on both axes.

 

Since: 3.24

Property Details

The “flags” property

  “flags”                    CtkEventControllerScrollFlags

The flags affecting event controller behavior

Owner: CtkEventControllerScroll

Flags: Read / Write

Since: 3.24

Signal Details

The “decelerate” signal

void
user_function (CtkEventControllerScroll *controller,
               double                    vel_x,
               double                    vel_y,
               gpointer                  user_data)

Emitted after scroll is finished if the CTK_EVENT_CONTROLLER_SCROLL_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.

Parameters

controller

The object that received the signal

 

vel_x

X velocity

 

vel_y

Y velocity

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “scroll” signal

void
user_function (CtkEventControllerScroll *controller,
               double                    dx,
               double                    dy,
               gpointer                  user_data)

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

Parameters

controller

The object that received the signal

 

dx

X delta

 

dy

Y delta

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “scroll-begin” signal

void
user_function (CtkEventControllerScroll *controller,
               gpointer                  user_data)

Signals that a new scrolling operation has begun. It will only be emitted on devices capable of it.

Parameters

controller

The object that received the signal

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “scroll-end” signal

void
user_function (CtkEventControllerScroll *controller,
               gpointer                  user_data)

Signals that a new scrolling operation has finished. It will only be emitted on devices capable of it.

Parameters

controller

The object that received the signal

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First

See Also

CtkEventController