Class EventControllerScroll
- All Implemented Interfaces:
Proxy
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
Gtk.EventControllerScroll::scroll
signal. Deltas in
the discrete case are multiples of 1.
In the case of continuous scroll events, GtkEventControllerScroll
encloses all Gtk.EventControllerScroll::scroll
emissions
between two Gtk.EventControllerScroll::scroll-begin
and
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
setFlags(java.util.Set<org.gnome.gtk.EventControllerScrollFlags>)
(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 EventControllerScrollFlags.VERTICAL
,
EventControllerScrollFlags.HORIZONTAL
and EventControllerScrollFlags.BOTH_AXES
.
If any axis is disabled, the respective 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 EventControllerScrollFlags.DISCRETE
. This can be used
to implement discrete actions triggered through scroll events (e.g.
switching across combobox options).
The EventControllerScrollFlags.KINETIC
flag toggles the emission of the
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theDecelerateCallback
callback.static class
static interface
Functional interface declaration of theScrollBeginCallback
callback.static interface
Functional interface declaration of theScrollCallback
callback.static interface
Functional interface declaration of theScrollEndCallback
callback.Nested classes/interfaces inherited from class org.gnome.gtk.EventController
EventController.EventControllerClass, EventController.EventControllerImpl
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionEventControllerScroll
(MemorySegment address) Create a EventControllerScroll proxy instance for the provided memory address.Creates a new event controller that will handle scroll events.Creates a new event controller that will handle scroll events. -
Method Summary
Modifier and TypeMethodDescriptionprotected EventControllerScroll
asParent()
Returns this instance as if it were its parent type.static EventControllerScroll.Builder
<? extends EventControllerScroll.Builder> builder()
AEventControllerScroll.Builder
object constructs aEventControllerScroll
with the specified properties.void
emitDecelerate
(double velX, double velY) Emits the "decelerate" signal.boolean
emitScroll
(double dx, double dy) Emits the "scroll" signal.void
Emits the "scroll-begin" signal.void
Emits the "scroll-end" signal.getFlags()
Gets the flags conditioning the scroll controller behavior.static Type
getType()
Get the GType of the EventControllerScroll classgetUnit()
Gets the scroll unit of the lastGtk.EventControllerScroll::scroll
signal received.Emitted after scroll is finished if theEventControllerScrollFlags.KINETIC
flag is set.Signals that the widget should scroll by the amount specified bydx
anddy
.Signals that a new scrolling operation has begun.Signals that a scrolling operation has finished.void
setFlags
(Set<EventControllerScrollFlags> flags) Sets the flags conditioning scroll controller behavior.void
setFlags
(EventControllerScrollFlags... flags) Sets the flags conditioning scroll controller behavior.Methods inherited from class org.gnome.gtk.EventController
getCurrentEvent, getCurrentEventDevice, getCurrentEventState, getCurrentEventTime, getName, getPropagationLimit, getPropagationPhase, getWidget, reset, setName, setPropagationLimit, setPropagationPhase, setStaticName
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
EventControllerScroll
Create a EventControllerScroll proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
EventControllerScroll
Creates a new event controller that will handle scroll events.- Parameters:
flags
- flags affecting the controller behavior
-
EventControllerScroll
Creates a new event controller that will handle scroll events.- Parameters:
flags
- flags affecting the controller behavior
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type.- Overrides:
asParent
in classEventController
-
getFlags
Gets the flags conditioning the scroll controller behavior.- Returns:
- the controller flags.
-
getUnit
Gets the scroll unit of the lastGtk.EventControllerScroll::scroll
signal received.Always returns
ScrollUnit.WHEEL
if theEventControllerScrollFlags.DISCRETE
flag is set.- Returns:
- the scroll unit.
-
setFlags
Sets the flags conditioning scroll controller behavior.- Parameters:
flags
- flags affecting the controller behavior
-
setFlags
Sets the flags conditioning scroll controller behavior.- Parameters:
flags
- flags affecting the controller behavior
-
onDecelerate
public SignalConnection<EventControllerScroll.DecelerateCallback> onDecelerate(EventControllerScroll.DecelerateCallback handler) Emitted after scroll is finished if theEventControllerScrollFlags.KINETIC
flag is set.velX
andvelY
express the initial velocity that was imprinted by the scroll events.velX
andvelY
are expressed in pixels/ms.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDecelerate
public void emitDecelerate(double velX, double velY) Emits the "decelerate" signal. SeeonDecelerate(org.gnome.gtk.EventControllerScroll.DecelerateCallback)
. -
onScroll
public SignalConnection<EventControllerScroll.ScrollCallback> onScroll(EventControllerScroll.ScrollCallback handler) Signals that the widget should scroll by the amount specified bydx
anddy
.For the representation unit of the deltas, see
getUnit()
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitScroll
public boolean emitScroll(double dx, double dy) Emits the "scroll" signal. SeeonScroll(org.gnome.gtk.EventControllerScroll.ScrollCallback)
. -
onScrollBegin
public SignalConnection<EventControllerScroll.ScrollBeginCallback> onScrollBegin(EventControllerScroll.ScrollBeginCallback handler) Signals that a new scrolling operation has begun.It will only be emitted on devices capable of it.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitScrollBegin
public void emitScrollBegin()Emits the "scroll-begin" signal. SeeonScrollBegin(org.gnome.gtk.EventControllerScroll.ScrollBeginCallback)
. -
onScrollEnd
public SignalConnection<EventControllerScroll.ScrollEndCallback> onScrollEnd(EventControllerScroll.ScrollEndCallback handler) Signals that a scrolling operation has finished.It will only be emitted on devices capable of it.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitScrollEnd
public void emitScrollEnd()Emits the "scroll-end" signal. SeeonScrollEnd(org.gnome.gtk.EventControllerScroll.ScrollEndCallback)
. -
builder
AEventControllerScroll.Builder
object constructs aEventControllerScroll
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withEventControllerScroll.Builder.build()
.
-