gtkmm: Gtk::EventControllerScroll Class Reference

gtkmm 4.12.0

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gtk::EventControllerScroll Class Reference
Event Controllers and Gestures

Event controller for scroll events. More...

`#include <gtkmm/eventcontrollerscroll.h>`

Inheritance diagram for Gtk::EventControllerScroll:
[legend]

## Public Types
enum class | Flags { NONE = 0x0 , VERTICAL = 1 << 0 , HORIZONTAL = 1 << 1 , DISCRETE = 1 << 2 , KINETIC = 1 << 3 , BOTH_AXES = 0x3 }
Public Types inherited from Glib::Object
typedef void(*)(gpointer data | DestroyNotify)

## Public Member Functions
| EventControllerScroll (EventControllerScroll && src) noexcept
EventControllerScroll & | operator= (EventControllerScroll && src) noexcept
| ~EventControllerScroll () noexcept override
GtkEventControllerScroll * | gobj ()
| Provides access to the underlying C GObject.
const GtkEventControllerScroll * | gobj () const
| Provides access to the underlying C GObject.
GtkEventControllerScroll * | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void | set_flags (Flags flags)
| Sets the flags conditioning scroll controller behavior.
Flags | get_flags () const
| Gets the flags conditioning the scroll controller behavior.
Gdk::ScrollUnit | get_unit () const
| Gets the scroll unit of the last signal_scroll() signal received.
Glib::PropertyProxy< Flags > | property_flags ()
| The flags affecting event controller behavior.
Glib::PropertyProxy_ReadOnly< Flags > | property_flags () const
| The flags affecting event controller behavior.
Glib::SignalProxy< void()> | signal_scroll_begin ()
Glib::SignalProxy< bool(double, double)> | signal_scroll ()
Glib::SignalProxy< void()> | signal_scroll_end ()
Glib::SignalProxy< void(double, double)> | signal_decelerate ()
Public Member Functions inherited from Gtk::EventController
| EventController (EventController && src) noexcept
EventController & | operator= (EventController && src) noexcept
| ~EventController () noexcept override
GtkEventController * | gobj ()
| Provides access to the underlying C GObject.
const GtkEventController * | gobj () const
| Provides access to the underlying C GObject.
GtkEventController * | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Widget * | get_widget ()
| Returns the `Gtk::Widget` this controller relates to.
const Widget * | get_widget () const
| Returns the `Gtk::Widget` this controller relates to.
void | reset ()
| Resets the controller to a clean state.
PropagationPhase | get_propagation_phase () const
| Gets the propagation phase at which controller handles events.
void | set_propagation_phase (PropagationPhase phase)
| Sets the propagation phase at which a controller handles events.
PropagationLimit | get_propagation_limit () const
| Gets the propagation limit of the event controller.
void | set_propagation_limit (PropagationLimit limit)
| Sets the event propagation limit on the event controller.
Glib::ustring | get_name () const
| Gets the name of controller.
void | set_name (const Glib::ustring & name)
| Sets a name on the controller that can be used for debugging.
Glib::RefPtr< const Gdk::Event > | get_current_event () const
| Returns the event that is currently being handled by the controller.
guint32 | get_current_event_time () const
| Returns the timestamp of the event that is currently being handled by the controller.
Glib::RefPtr< Gdk::Device > | get_current_event_device ()
| Returns the device of the event that is currently being handled by the controller.
Glib::RefPtr< const Gdk::Device > | get_current_event_device () const
| Returns the event that is currently being handled by the controller.
Gdk::ModifierType | get_current_event_state () const
| Returns the modifier state of the event that is currently being handled by the controller.
Glib::PropertyProxy_ReadOnly< Widget * > | property_widget () const
| The widget receiving the `Gdk::Events` that the controller will handle.
Glib::PropertyProxy< PropagationPhase > | property_propagation_phase ()
| The propagation phase at which this controller will handle events.
Glib::PropertyProxy_ReadOnly< PropagationPhase > | property_propagation_phase () const
| The propagation phase at which this controller will handle events.
Glib::PropertyProxy< PropagationLimit > | property_propagation_limit ()
| The limit for which events this controller will handle.
Glib::PropertyProxy_ReadOnly< PropagationLimit > | property_propagation_limit () const
| The limit for which events this controller will handle.
Glib::PropertyProxy< Glib::ustring > | property_name ()
| The name for this controller, typically used for debugging purposes.
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_name () const
| The name for this controller, typically used for debugging purposes.
Public Member Functions inherited from Glib::Object
| Object (const Object &)=delete
Object & | operator= (const Object &)=delete
| Object (Object &&src) noexcept
Object & | operator= (Object &&src) noexcept
void * | get_data (const QueryQuark &key)
void | set_data (const Quark &key, void *data)
void | set_data (const Quark &key, void *data, DestroyNotify notify)
void | remove_data (const QueryQuark &quark)
void * | steal_data (const QueryQuark &quark)
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase &)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
void | set_property (const Glib::ustring &property_name, const PropertyType &value)
void | get_property (const Glib::ustring &property_name, PropertyType &value) const
PropertyType | get_property (const Glib::ustring &property_name) const
sigc::connection | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
sigc::connection | connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
void | freeze_notify ()
void | thaw_notify ()
virtual void | reference () const
virtual void | unreference () const
GObject * | gobj ()
const GObject * | gobj () const
GObject * | gobj_copy () const

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system.
static Glib::RefPtr< EventControllerScroll > | create ()
Static Public Member Functions inherited from Gtk::EventController
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system.

## Protected Member Functions
| EventControllerScroll ()
Protected Member Functions inherited from Gtk::EventController
| EventController ()
| There is no create() method that corresponds to this constructor, because only derived classes shall be created.
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams &construct_params)
| Object (GObject *castitem)
| ~Object () noexcept override
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| ObjectBase (const char *custom_type_name)
| ObjectBase (const std::type_info &custom_type_info)
| ObjectBase (ObjectBase &&src) noexcept
ObjectBase & | operator= (ObjectBase &&src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject *castitem)
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)

## Related Symbols
(Note that these are not member symbols.)
Glib::RefPtr< Gtk::EventControllerScroll > | wrap (GtkEventControllerScroll * object, bool take_copy=false)
| A Glib::wrap() method for this object.
Related Symbols inherited from Gtk::EventController
Glib::RefPtr< Gtk::EventController > | wrap (GtkEventController * object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

Event controller for scroll events.

Gtk::EventControllerScroll 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 signal_scroll() signal (deltas in the discrete case are multiples of 1).

In the case of continuous scroll events, EventControllerScroll encloses all signal_scroll() events between two signal_scroll_begin() and signal_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 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::EventControllerScroll::Flags::VERTICAL, Gtk::EventControllerScroll::Flags::HORIZONTAL and Gtk::EventControllerScroll::Flags::BOTH_AXES. If any axis is disabled, the respective signal_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::EventControllerScroll::Flags::DISCRETE. This can be used to implement discrete actions triggered through scroll events (e.g. switching across combobox options).

The Gtk::EventControllerScroll::Flags::KINETIC flag toggles the emission of the signal_decelerate() signal, emitted at the end of scrolling with two X/Y velocity arguments that are consistent with the motion that was received.

Since gtkmm 3.94:

## Member Enumeration Documentation

## ◆ Flags

enum class Gtk::EventControllerScroll::Flags
| strong

Enumerator
NONE | Don't emit scroll.
VERTICAL | Emit scroll with vertical deltas.
HORIZONTAL | Emit scroll with horizontal deltas.
DISCRETE | Only emit deltas that are multiples of 1.
KINETIC | Emit signal_decelerate() after continuous scroll finishes.
BOTH_AXES | Emit scroll on both axes.

## Constructor & Destructor Documentation

## ◆ EventControllerScroll() [1/2]

Gtk::EventControllerScroll::EventControllerScroll | ( | EventControllerScroll && | src | ) |
| noexcept

## ◆ ~EventControllerScroll()

Gtk::EventControllerScroll::~EventControllerScroll | ( |  | ) |
| overridenoexcept

## ◆ EventControllerScroll() [2/2]

Gtk::EventControllerScroll::EventControllerScroll | ( |  | ) |
| protected

## Member Function Documentation

## ◆ create()

static Glib::RefPtr< EventControllerScroll > Gtk::EventControllerScroll::create | ( |  | ) |
| static

## ◆ get_flags()

Flags Gtk::EventControllerScroll::get_flags | ( |  | ) | const

Gets the flags conditioning the scroll controller behavior.

Returns
  The controller flags.

## ◆ get_type()

static GType Gtk::EventControllerScroll::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

## ◆ get_unit()

Gdk::ScrollUnit Gtk::EventControllerScroll::get_unit | ( |  | ) | const

Gets the scroll unit of the last signal_scroll() signal received.

Always returns Gdk::ScrollUnit::WHEEL if the Gtk::EventControllerScroll::Flags::DISCRETE flag is set.

Since gtkmm 4.8:

Returns
  The scroll unit.

## ◆ gobj() [1/2]

GtkEventControllerScroll * Gtk::EventControllerScroll::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GtkEventControllerScroll * Gtk::EventControllerScroll::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ gobj_copy()

GtkEventControllerScroll * Gtk::EventControllerScroll::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

## ◆ operator=()

EventControllerScroll & Gtk::EventControllerScroll::operator= | ( | EventControllerScroll && | src | ) |
| noexcept

## ◆ property_flags() [1/2]

Glib::PropertyProxy< Flags > Gtk::EventControllerScroll::property_flags | ( |  | ) |

The flags affecting event controller behavior.

Default value: Gtk::EventControllerScroll::Flags::NONE

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_flags() [2/2]

Glib::PropertyProxy_ReadOnly< Flags > Gtk::EventControllerScroll::property_flags | ( |  | ) | const

The flags affecting event controller behavior.

Default value: Gtk::EventControllerScroll::Flags::NONE

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ set_flags()

void Gtk::EventControllerScroll::set_flags | ( | Flags | flags | ) |

Sets the flags conditioning scroll controller behavior.

Parameters

  flags | Flags affecting the controller behavior.

## ◆ signal_decelerate()

Glib::SignalProxy< void(double, double)> Gtk::EventControllerScroll::signal_decelerate | ( |  | ) |

Slot Prototype:
  `void on_my_decelerate(double vel_x, double vel_y)`

Flags: Run First

Emitted after scroll is finished if the Gtk::EventControllerScroll::Flags::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

  vel_x | X velocity.
  vel_y | Y velocity.

## ◆ signal_scroll()

Glib::SignalProxy< bool(double, double)> Gtk::EventControllerScroll::signal_scroll | ( |  | ) |

Slot Prototype:
  `bool on_my_scroll(double dx, double dy)`

Flags: Run Last

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

For the representation unit of the deltas, see Gtk::EventControllerScroll::get_unit().

Parameters

  dx | X delta.
  dy | Y delta.

Returns
  `true` if the scroll event was handled, `false` otherwise.

## ◆ signal_scroll_begin()

Glib::SignalProxy< void()> Gtk::EventControllerScroll::signal_scroll_begin | ( |  | ) |

Slot Prototype:
  `void on_my_scroll_begin()`

Flags: Run First

Signals that a new scrolling operation has begun.

It will only be emitted on devices capable of it.

## ◆ signal_scroll_end()

Glib::SignalProxy< void()> Gtk::EventControllerScroll::signal_scroll_end | ( |  | ) |

Slot Prototype:
  `void on_my_scroll_end()`

Flags: Run First

Signals that a scrolling operation has finished.

It will only be emitted on devices capable of it.

## Friends And Related Symbol Documentation

## ◆ wrap()

Glib::RefPtr< Gtk::EventControllerScroll > wrap | ( | GtkEventControllerScroll * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.