Table of Contents

Class ScrollContainer

Namespace
Godot
Assembly
GodotSharp.dll

A container used to provide a child control with scrollbars when needed. Scrollbars will automatically be drawn at the right (for vertical) or bottom (for horizontal) and will enable dragging to move the viewable Control (and its children) within the ScrollContainer. Scrollbars will also automatically resize the grabber based on the CustomMinimumSize of the Control relative to the ScrollContainer.

public class ScrollContainer : Container, IDisposable
Inheritance
ScrollContainer
Implements
Inherited Members

Constructors

ScrollContainer()

public ScrollContainer()

Properties

FollowFocus

If true, the ScrollContainer will automatically scroll to focused children (including indirect children) to make sure they are fully visible.

public bool FollowFocus { get; set; }

Property Value

bool

HorizontalScrollMode

Controls whether horizontal scrollbar can be used and when it should be visible. See ScrollContainer.ScrollMode for options.

public ScrollContainer.ScrollMode HorizontalScrollMode { get; set; }

Property Value

ScrollContainer.ScrollMode

ScrollDeadzone

Deadzone for touch scrolling. Lower deadzone makes the scrolling more sensitive.

public int ScrollDeadzone { get; set; }

Property Value

int

ScrollHorizontal

The current horizontal scroll value.

Note: If you are setting this value in the _Ready() function or earlier, it needs to be wrapped with SetDeferred(StringName, Variant), since scroll bar's MaxValue is not initialized yet.

func _ready():
      set_deferred("scroll_horizontal", 600)
public int ScrollHorizontal { get; set; }

Property Value

int

ScrollHorizontalCustomStep

Overrides the CustomStep used when clicking the internal scroll bar's horizontal increment and decrement buttons or when using arrow keys when the ScrollBar is focused.

public float ScrollHorizontalCustomStep { get; set; }

Property Value

float

ScrollVertical

The current vertical scroll value.

Note: Setting it early needs to be deferred, just like in ScrollHorizontal.

func _ready():
      set_deferred("scroll_vertical", 600)
public int ScrollVertical { get; set; }

Property Value

int

ScrollVerticalCustomStep

Overrides the CustomStep used when clicking the internal scroll bar's vertical increment and decrement buttons or when using arrow keys when the ScrollBar is focused.

public float ScrollVerticalCustomStep { get; set; }

Property Value

float

VerticalScrollMode

Controls whether vertical scrollbar can be used and when it should be visible. See ScrollContainer.ScrollMode for options.

public ScrollContainer.ScrollMode VerticalScrollMode { get; set; }

Property Value

ScrollContainer.ScrollMode

Methods

EnsureControlVisible(Control)

Ensures the given control is visible (must be a direct or indirect child of the ScrollContainer). Used by FollowFocus.

Note: This will not work on a node that was just added during the same frame. If you want to scroll to a newly added child, you must wait until the next frame using ProcessFrame:

add_child(child_node)
  await get_tree().process_frame
  ensure_control_visible(child_node)
public void EnsureControlVisible(Control control)

Parameters

control Control

GetHScrollBar()

Returns the horizontal scrollbar HScrollBar of this ScrollContainer.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to disable or hide a scrollbar, you can use HorizontalScrollMode.

public HScrollBar GetHScrollBar()

Returns

HScrollBar

GetVScrollBar()

Returns the vertical scrollbar VScrollBar of this ScrollContainer.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to disable or hide a scrollbar, you can use VerticalScrollMode.

public VScrollBar GetVScrollBar()

Returns

VScrollBar

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

Events

ScrollEnded

Emitted when scrolling stops when dragging the scrollable area with a touch event. This signal is not emitted when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.

Note: This signal is only emitted on Android or iOS, or on desktop/web platforms when ProjectSettings.input_devices/pointing/emulate_touch_from_mouse is enabled.

public event Action ScrollEnded

Event Type

Action

ScrollStarted

Emitted when scrolling starts when dragging the scrollable area with a touch event. This signal is not emitted when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.

Note: This signal is only emitted on Android or iOS, or on desktop/web platforms when ProjectSettings.input_devices/pointing/emulate_touch_from_mouse is enabled.

public event Action ScrollStarted

Event Type

Action