1.167 <GtkScrolledWindow>

Class: <GtkScrolledWindow>

It derives from <GtkWidget>.

Makes its child scrollable.

It does so using either internally added scrollbars or externally associated adjustments, and optionally draws a frame around the child.

Widgets with native scrolling support, i.e. those whose classes implement the <GtkScrollable> interface, are added directly. For other types of widget, the class <GtkViewport> acts as an adaptor, giving scrollability to other widgets. scrolled-window:set-child intelligently accounts for whether or not the added child is a <GtkScrollable>. If it isn’t, then it wraps the child in a <GtkViewport>. Therefore, you can just add any child widget and not worry about the details.

If scrolled-window:set-child has added a <GtkViewport> for you, it will be automatically removed when you unset the child. Unless scrolled-window:hscrollbar-policy and scrolled-window:vscrollbar-policy are never or external, <GtkScrolledWindow> adds internal <GtkScrollbar> widgets around its child. The scroll position of the child, and if applicable the scrollbars, is controlled by the scrolled-window:hadjustment and scrolled-window:vadjustment that are associated with the <GtkScrolledWindow>. See the docs on <GtkScrollbar> for the details, but note that the “step_increment” and “page_increment” fields are only effective if the policy causes scrollbars to be present.

If a <GtkScrolledWindow> doesn’t behave quite as you would like, or doesn’t have exactly the right layout, it’s very possible to set up your own scrolling with <GtkScrollbar> and for example a <GtkGrid>.

Touch support

<GtkScrolledWindow> has built-in support for touch devices. When a touchscreen is used, swiping will move the scrolled window, and will expose ’kinetic’ behavior. This can be turned off with the scrolled-window:kinetic-scrolling property if it is undesired.

<GtkScrolledWindow> also displays visual ’overshoot’ indication when the content is pulled beyond the end, and this situation can be captured with the scrolled-window:edge-overshot signal.

If no mouse device is present, the scrollbars will overlaid as narrow, auto-hiding indicators over the content. If traditional scrollbars are desired although no mouse is present, this behaviour can be turned off with the scrolled-window:overlay-scrolling property.

Shortcuts and Gestures

The following signals have default keybindings:

CSS nodes

<GtkScrolledWindow> has a main CSS node with name scrolledwindow. It gets a .frame style class added when scrolled-window:has-frame is #t.

It uses subnodes with names overshoot and undershoot to draw the overflow and underflow indications. These nodes get the .left, .right, .top or .bottom style class added depending on where the indication is drawn.

<GtkScrolledWindow> also sets the positional style classes (.left, .right, .top, .bottom) and style classes related to overlay scrolling (.overlay-indicator, .dragging, .hovering) on its scrollbars.

If both scrollbars are visible, the area where they meet is drawn with a subnode named junction.

Accessibility

Until GTK 4.10, <GtkScrolledWindow> used the Gtk.AccessibleRole.group role.

Starting from GTK 4.12, <GtkScrolledWindow> uses the Gtk.AccessibleRole.generic role.

Properties

Property: scrolled-window:child self

The child widget.

When setting this property, if the child widget does not implement <GtkScrollable>, the scrolled window will add the child to a <GtkViewport> and then set the viewport as the child.

Its value is a <GtkWidget>, or #f.

Set it with (set! (scrolled-window:child self) value).

Property: scrolled-window:hadjustment self

The <GtkAdjustment> for the horizontal position.

Its value is a <GtkAdjustment>, or #f.

Set it with (set! (scrolled-window:hadjustment self) value).

Property: scrolled-window:has-frame self

Whether to draw a frame around the contents.

Its value is a boolean.

Set it with (set! (scrolled-window:has-frame self) value).

Property: scrolled-window:hscrollbar-policy self

When the horizontal scrollbar is displayed.

Use scrolled-window:set-policy to set this property.

Its value is a <GtkPolicyType> (or, to set it, one of its symbols).

Set it with (set! (scrolled-window:hscrollbar-policy self) value).

Property: scrolled-window:kinetic-scrolling self

Whether kinetic scrolling is enabled or not.

Kinetic scrolling only applies to devices with source touchscreen.

Its value is a boolean.

Set it with (set! (scrolled-window:kinetic-scrolling self) value).

Property: scrolled-window:max-content-height self

The maximum content height of scrolled-window.

Its value is a 32-bit integer.

Set it with (set! (scrolled-window:max-content-height self) value).

Property: scrolled-window:max-content-width self

The maximum content width of scrolled-window.

Its value is a 32-bit integer.

Set it with (set! (scrolled-window:max-content-width self) value).

Property: scrolled-window:min-content-height self

The minimum content height of scrolled-window.

Its value is a 32-bit integer.

Set it with (set! (scrolled-window:min-content-height self) value).

Property: scrolled-window:min-content-width self

The minimum content width of scrolled-window.

Its value is a 32-bit integer.

Set it with (set! (scrolled-window:min-content-width self) value).

Property: scrolled-window:overlay-scrolling self

Whether overlay scrolling is enabled or not.

If it is, the scrollbars are only added as traditional widgets when a mouse is present. Otherwise, they are overlaid on top of the content, as narrow indicators.

Note that overlay scrolling can also be globally disabled, with the settings:gtk-overlay-scrolling setting.

Its value is a boolean.

Set it with (set! (scrolled-window:overlay-scrolling self) value).

Property: scrolled-window:propagate-natural-height self

Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.

This is useful in cases where an attempt should be made to allocate exactly enough space for the natural size of the child.

Its value is a boolean.

Set it with (set! (scrolled-window:propagate-natural-height self) value).

Property: scrolled-window:propagate-natural-width self

Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.

This is useful in cases where an attempt should be made to allocate exactly enough space for the natural size of the child.

Its value is a boolean.

Set it with (set! (scrolled-window:propagate-natural-width self) value).

Property: scrolled-window:vadjustment self

The <GtkAdjustment> for the vertical position.

Its value is a <GtkAdjustment>, or #f.

Set it with (set! (scrolled-window:vadjustment self) value).

Property: scrolled-window:vscrollbar-policy self

When the vertical scrollbar is displayed.

Use scrolled-window:set-policy to set this property.

Its value is a <GtkPolicyType> (or, to set it, one of its symbols).

Set it with (set! (scrolled-window:vscrollbar-policy self) value).

Property: scrolled-window:window-placement self

Where the contents are located with respect to the scrollbars.

Its value is a <GtkCornerType> (or, to set it, one of its symbols).

Set it with (set! (scrolled-window:window-placement self) value).

Procedures

Method: scrolled-window:get-child self ⇒ %return
Method: get-child self ⇒ %return

Gets the child widget of self.

If the scrolled window automatically added a <GtkViewport>, this function will return the viewport widget, and you can retrieve its child using viewport:get-child.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a <GtkWidget>, or #f.

the child widget of self

Method: scrolled-window:get-hadjustment self ⇒ %return
Method: get-hadjustment self ⇒ %return

Returns the horizontal scrollbar’s adjustment.

This is the adjustment used to connect the horizontal scrollbar to the child widget’s horizontal scroll functionality.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a <GtkAdjustment>.

the horizontal <GtkAdjustment>

Method: scrolled-window:get-has-frame? self ⇒ %return
Method: get-has-frame? self ⇒ %return

Gets whether the scrolled window draws a frame.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a boolean.

#t if the self has a frame

Method: scrolled-window:get-hscrollbar self ⇒ %return
Method: get-hscrollbar self ⇒ %return

Returns the horizontal scrollbar of self.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a <GtkWidget>.

the horizontal scrollbar of the scrolled window.

Method: scrolled-window:get-kinetic-scrolling? self ⇒ %return
Method: get-kinetic-scrolling? self ⇒ %return

Returns the specified kinetic scrolling behavior.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a boolean.

the scrolling behavior flags.

Method: scrolled-window:get-max-content-height self ⇒ %return
Method: get-max-content-height self ⇒ %return

Returns the maximum content height set.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a 32-bit integer.

the maximum content height, or -1

Method: scrolled-window:get-max-content-width self ⇒ %return
Method: get-max-content-width self ⇒ %return

Returns the maximum content width set.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a 32-bit integer.

the maximum content width, or -1

Method: scrolled-window:get-min-content-height self ⇒ %return
Method: get-min-content-height self ⇒ %return

Gets the minimal content height of self.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a 32-bit integer.

the minimal content height

Method: scrolled-window:get-min-content-width self ⇒ %return
Method: get-min-content-width self ⇒ %return

Gets the minimum content width of self.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a 32-bit integer.

the minimum content width

Method: scrolled-window:get-overlay-scrolling? self ⇒ %return
Method: get-overlay-scrolling? self ⇒ %return

Returns whether overlay scrolling is enabled for this scrolled window.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a boolean.

#t if overlay scrolling is enabled

Method: scrolled-window:get-placement self ⇒ %return
Method: get-placement self ⇒ %return

Gets the placement of the contents with respect to the scrollbars.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a <GtkCornerType>.

the current placement value.

Method: scrolled-window:get-policy self ⇒ hscrollbar-policy vscrollbar-policy
Method: get-policy self ⇒ hscrollbar-policy vscrollbar-policy

Retrieves the current policy values for the horizontal and vertical scrollbars.

See scrolled-window:set-policy.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

hscrollbar-policy

Returned: a <GtkPolicyType>.

location to store the policy for the horizontal scrollbar

vscrollbar-policy

Returned: a <GtkPolicyType>.

location to store the policy for the vertical scrollbar

Method: scrolled-window:get-propagate-natural-height? self ⇒ %return
Method: get-propagate-natural-height? self ⇒ %return

Reports whether the natural height of the child will be calculated and propagated through the scrolled window’s requested natural height.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a boolean.

whether natural height propagation is enabled.

Method: scrolled-window:get-propagate-natural-width? self ⇒ %return
Method: get-propagate-natural-width? self ⇒ %return

Reports whether the natural width of the child will be calculated and propagated through the scrolled window’s requested natural width.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a boolean.

whether natural width propagation is enabled.

Method: scrolled-window:get-vadjustment self ⇒ %return
Method: get-vadjustment self ⇒ %return

Returns the vertical scrollbar’s adjustment.

This is the adjustment used to connect the vertical scrollbar to the child widget’s vertical scroll functionality.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a <GtkAdjustment>.

the vertical <GtkAdjustment>

Method: scrolled-window:get-vscrollbar self ⇒ %return
Method: get-vscrollbar self ⇒ %return

Returns the vertical scrollbar of self.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

%return

Returned: a <GtkWidget>.

the vertical scrollbar of the scrolled window.

Procedure: scrolled-window:new ⇒ %return

Creates a new scrolled window.

%return

Returned: a <GtkWidget>.

a new scrolled window

Method: scrolled-window:set-child self [child]
Method: set-child self [child]

Sets the child widget of self.

If child does not implement the <GtkScrollable> interface, the scrolled window will add child to a <GtkViewport> instance and then add the viewport as its child widget.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

child

Passed, or left out: a <GtkWidget>, or #f.

the child widget

Method: scrolled-window:set-hadjustment self [hadjustment]
Method: set-hadjustment self [hadjustment]

Sets the <GtkAdjustment> for the horizontal scrollbar.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

hadjustment

Passed, or left out: a <GtkAdjustment>, or #f.

the <GtkAdjustment> to use, or #f to create a new one

Method: scrolled-window:set-has-frame self has-frame
Method: set-has-frame self has-frame

Changes the frame drawn around the contents of self.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

has-frame

Passed: a boolean.

whether to draw a frame around scrolled window contents

Method: scrolled-window:set-kinetic-scrolling self kinetic-scrolling
Method: set-kinetic-scrolling self kinetic-scrolling

Turns kinetic scrolling on or off.

Kinetic scrolling only applies to devices with source touchscreen.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

kinetic-scrolling

Passed: a boolean.

#t to enable kinetic scrolling

Method: scrolled-window:set-max-content-height self height
Method: set-max-content-height self height

Sets the maximum height that self should keep visible.

The self will grow up to this height before it starts scrolling the content.

It is a programming error to set the maximum content height to a value smaller than scrolled-window:min-content-height.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

height

Passed: a 32-bit integer.

the maximum content height

Method: scrolled-window:set-max-content-width self width
Method: set-max-content-width self width

Sets the maximum width that self should keep visible.

The self will grow up to this width before it starts scrolling the content.

It is a programming error to set the maximum content width to a value smaller than scrolled-window:min-content-width.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

width

Passed: a 32-bit integer.

the maximum content width

Method: scrolled-window:set-min-content-height self height
Method: set-min-content-height self height

Sets the minimum height that self should keep visible.

Note that this can and (usually will) be smaller than the minimum size of the content.

It is a programming error to set the minimum content height to a value greater than scrolled-window:max-content-height.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

height

Passed: a 32-bit integer.

the minimal content height

Method: scrolled-window:set-min-content-width self width
Method: set-min-content-width self width

Sets the minimum width that self should keep visible.

Note that this can and (usually will) be smaller than the minimum size of the content.

It is a programming error to set the minimum content width to a value greater than scrolled-window:max-content-width.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

width

Passed: a 32-bit integer.

the minimal content width

Method: scrolled-window:set-overlay-scrolling self overlay-scrolling
Method: set-overlay-scrolling self overlay-scrolling

Enables or disables overlay scrolling for this scrolled window.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

overlay-scrolling

Passed: a boolean.

whether to enable overlay scrolling

Method: scrolled-window:set-placement self window-placement
Method: set-placement self window-placement

Sets the placement of the contents with respect to the scrollbars for the scrolled window.

The default is top-left, meaning the child is in the top left, with the scrollbars underneath and to the right. Other values in <GtkCornerType> are top-right, bottom-left, and bottom-right.

See also scrolled-window:get-placement and scrolled-window:unset-placement.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

window-placement

Passed: a <GtkCornerType>, or one of its symbols.

position of the child window

Method: scrolled-window:set-policy self hscrollbar-policy vscrollbar-policy
Method: set-policy self hscrollbar-policy vscrollbar-policy

Sets the scrollbar policy for the horizontal and vertical scrollbars.

The policy determines when the scrollbar should appear; it is a value from the <GtkPolicyType> enumeration. If always, the scrollbar is always present; if never, the scrollbar is never present; if automatic, the scrollbar is present only if needed (that is, if the slider part of the bar would be smaller than the trough — the display is larger than the page size).

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

hscrollbar-policy

Passed: a <GtkPolicyType>, or one of its symbols.

policy for horizontal bar

vscrollbar-policy

Passed: a <GtkPolicyType>, or one of its symbols.

policy for vertical bar

Method: scrolled-window:set-propagate-natural-height self propagate
Method: set-propagate-natural-height self propagate

Sets whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

propagate

Passed: a boolean.

whether to propagate natural height

Method: scrolled-window:set-propagate-natural-width self propagate
Method: set-propagate-natural-width self propagate

Sets whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

propagate

Passed: a boolean.

whether to propagate natural width

Method: scrolled-window:set-vadjustment self [vadjustment]
Method: set-vadjustment self [vadjustment]

Sets the <GtkAdjustment> for the vertical scrollbar.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

vadjustment

Passed, or left out: a <GtkAdjustment>, or #f.

the <GtkAdjustment> to use, or #f to create a new one

Method: scrolled-window:unset-placement self
Method: unset-placement self

Unsets the placement of the contents with respect to the scrollbars.

If no window placement is set for a scrolled window, it defaults to top-left.

self

Passed: a <GtkScrolledWindow>.

a <GtkScrolledWindow>

Signals

Signal: scrolled-window:edge-overshot

Connect a handler with (connect object scrolled-window:edge-overshot handler). It is called as (handler self pos).

Emitted whenever user initiated scrolling makes the scrolled window firmly surpass the limits defined by the adjustment in that orientation.

A similar behavior without edge resistance is provided by the scrolled-window:edge-reached signal.

Note: The pos argument is LTR/RTL aware, so callers should be aware too if intending to provide behavior on horizontal edges.

self

Passed: a <GtkScrolledWindow>.

pos

Passed: a <GtkPositionType>.

edge side that was hit

Signal: scrolled-window:edge-reached

Connect a handler with (connect object scrolled-window:edge-reached handler). It is called as (handler self pos).

Emitted whenever user-initiated scrolling makes the scrolled window exactly reach the lower or upper limits defined by the adjustment in that orientation.

A similar behavior with edge resistance is provided by the scrolled-window:edge-overshot signal.

Note: The pos argument is LTR/RTL aware, so callers should be aware too if intending to provide behavior on horizontal edges.

self

Passed: a <GtkScrolledWindow>.

pos

Passed: a <GtkPositionType>.

edge side that was reached

Signal: scrolled-window:move-focus-out

Connect a handler with (connect object scrolled-window:move-focus-out handler). It is called as (handler self direction-type).

Emitted when focus is moved away from the scrolled window by a keybinding.

This is a keybinding signal.

The default bindings for this signal are Ctrl+Tab to move forward and Ctrl+Shift+Tab‘ to move backward.

self

Passed: a <GtkScrolledWindow>.

direction-type

Passed: a <GtkDirectionType>.

either tab-forward or tab-backward

Signal: scrolled-window:scroll-child

Connect a handler with (connect object scrolled-window:scroll-child handler). It is called as (handler self scroll horizontal) ⇒ %return.

Emitted when a keybinding that scrolls is pressed.

This is a keybinding signal.

The horizontal or vertical adjustment is updated which triggers a signal that the scrolled window’s child may listen to and scroll itself.

self

Passed: a <GtkScrolledWindow>.

scroll

Passed: a <GtkScrollType>.

a <GtkScrollType> describing how much to scroll

horizontal

Passed: a boolean.

whether the keybinding scrolls the child horizontally or not

%return

Returned: a boolean.

whether the scroll happened