Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

ScrollContainer

Hérite de : Container < Control < CanvasItem < Node < Object

Hérité par : EditorInspector

Un conteneur utilisé pour fournir des barres de défilement à un contrôle enfant au besoin.

Description

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 Control.custom_minimum_size of the Control relative to the ScrollContainer.

Tutoriels

Propriétés

bool

clip_contents

true (overrides Control)

bool

draw_focus_border

false

bool

follow_focus

false

ScrollMode

horizontal_scroll_mode

1

bool

propagate_maximum_size

false (overrides Control)

int

scroll_deadzone

0

ScrollHintMode

scroll_hint_mode

0

int

scroll_horizontal

0

bool

scroll_horizontal_by_default

false

float

scroll_horizontal_custom_step

-1.0

int

scroll_vertical

0

float

scroll_vertical_custom_step

-1.0

bool

tile_scroll_hint

false

ScrollMode

vertical_scroll_mode

1

Méthodes

void

ensure_control_visible(control: Control)

HScrollBar

get_h_scroll_bar()

VScrollBar

get_v_scroll_bar()

Propriétés du thème

Color

scroll_hint_horizontal_color

Color(0, 0, 0, 1)

Color

scroll_hint_vertical_color

Color(0, 0, 0, 1)

int

scrollbar_h_separation

0

int

scrollbar_v_separation

0

Texture2D

scroll_hint_horizontal

Texture2D

scroll_hint_vertical

StyleBox

focus

StyleBox

panel


Signaux

scroll_ended() 🔗

Émis lorsque le défilement s'arrête lors du glissement de la zone défilante avec un événement tactile. Ce signal n'est pas émis lors du défilement en faisant glisser la barre de défilement, en défilant avec la roue de la souris ou en défilant avec des événements de clavier/manette.

Note : Ce signal n'est émis que sur Android ou iOS, ou sur les plateformes de bureau/web lorsque ProjectSettings.input_devices/pointing/emulate_touch_from_mouse est activé.


scroll_started() 🔗

Émis lorsque le défilement commence lors du glissement de la zone défilante avec un événement tactile. Ce signal n'est pas émis lors du défilement en faisant glisser la barre de défilement, en défilant avec la roue de la souris ou en défilant avec des événements de clavier/manette.

Note : Ce signal n'est émis que sur Android ou iOS, ou sur les plateformes de bureau/web lorsque ProjectSettings.input_devices/pointing/emulate_touch_from_mouse est activé.


Énumérations

enum ScrollMode: 🔗

ScrollMode SCROLL_MODE_DISABLED = 0

Défilement désactivé, la barre de défilement sera invisible.

ScrollMode SCROLL_MODE_AUTO = 1

Défilement activé, la barre de défilement ne sera visible que si nécessaire, c'est-à-dire que le contenu du conteneur est plus grand que le conteneur.

ScrollMode SCROLL_MODE_SHOW_ALWAYS = 2

Défilement activé, la barre de défilement sera toujours visible.

ScrollMode SCROLL_MODE_SHOW_NEVER = 3

Défilement activé, la barre de défilement sera cachée.

ScrollMode SCROLL_MODE_RESERVE = 4

Combine SCROLL_MODE_AUTO et SCROLL_MODE_SHOW_ALWAYS. La barre de défilement n'est visible que si nécessaire, mais la taille du contenu est ajustée comme si elle était toujours visible. Utile pour s'assurer que la taille du contenu reste la même peu importe si la barre de défilement est visible.

ScrollMode SCROLL_MODE_MAXIMIZE_FIRST = 5

Behaves like SCROLL_MODE_AUTO, but makes the ScrollContainer report a minimum size based on its content (limited by Control.custom_maximum_size when set on the corresponding axis). This allows it to grow first and only start scrolling once constrained.


enum ScrollHintMode: 🔗

ScrollHintMode SCROLL_HINT_MODE_DISABLED = 0

Scroll hints will never be shown.

ScrollHintMode SCROLL_HINT_MODE_ALL = 1

Scroll hints will be shown at the top and bottom (if vertical), or left and right (if horizontal).

ScrollHintMode SCROLL_HINT_MODE_TOP_AND_LEFT = 2

Scroll hints will be shown at the top (if vertical), or the left (if horizontal).

ScrollHintMode SCROLL_HINT_MODE_BOTTOM_AND_RIGHT = 3

Scroll hints will be shown at the bottom (if horizontal), or the right (if horizontal).


Descriptions des propriétés

bool draw_focus_border = false 🔗

  • void set_draw_focus_border(value: bool)

  • bool get_draw_focus_border()

Si true, focus est dessiné lorsque le ScrollContainer ou l'un de ses nœuds descendants a le focus.


bool follow_focus = false 🔗

  • void set_follow_focus(value: bool)

  • bool is_following_focus()

Si true, le ScrollContainer défilera automatiquement vers les enfants ayant le focus (y compris les enfants indirects) pour s'assurer qu'ils soient pleinement visibles.


ScrollMode horizontal_scroll_mode = 1 🔗

Contrôle si la barre de défilement horizontale peut être utilisée et quand elle devrait être visible.


int scroll_deadzone = 0 🔗

  • void set_deadzone(value: int)

  • int get_deadzone()

Zone morte pour le défilement tactile. Une zone morte plus basse rend le défilement plus sensible.


ScrollHintMode scroll_hint_mode = 0 🔗

The way which scroll hints (indicators that show that the content can still be scrolled in a certain direction) will be shown.

Note: Hints won't be shown if the content can be scrolled both vertically and horizontally.


int scroll_horizontal = 0 🔗

  • void set_h_scroll(value: int)

  • int get_h_scroll()

La valeur de défilement horizontal actuelle.

Note : Si vous définissez cette valeur dans la fonction Node._ready() ou plus tôt, elle doit être définie avec Object.set_deferred(), puisque la Range.max_value de la barre de défilement n'est pas encore initialisée.

func _ready():
    set_deferred("scroll_horizontal", 600)

bool scroll_horizontal_by_default = false 🔗

  • void set_scroll_horizontal_by_default(value: bool)

  • bool is_scroll_horizontal_by_default()

If true, the mouse wheel scrolls the view horizontally, and holding Shift scrolls vertically.

If false (default), the mouse wheel scrolls the view vertically, and holding Shift scrolls horizontally.


float scroll_horizontal_custom_step = -1.0 🔗

  • void set_horizontal_custom_step(value: float)

  • float get_horizontal_custom_step()

Redéfinit le ScrollBar.custom_step utilisé lorsque vous cliquez sur les boutons d'incrément et de décrément horizontaux de la barre de défilement ou lorsque vous utilisez des touches directionnelles lorsque la ScrollBar a le focus.


int scroll_vertical = 0 🔗

  • void set_v_scroll(value: int)

  • int get_v_scroll()

La valeur de défilement vertical actuelle.

Note : La définir tôt doit être fait en différé, comme avec scroll_horizontal.

func _ready():
    set_deferred("scroll_vertical", 600)

float scroll_vertical_custom_step = -1.0 🔗

  • void set_vertical_custom_step(value: float)

  • float get_vertical_custom_step()

Redéfinit le ScrollBar.custom_step utilisé lorsque vous cliquez sur les boutons d'incrément et de décrément verticaux de la barre de défilement ou lorsque vous utilisez des touches directionnelles lorsque la ScrollBar a le focus.


bool tile_scroll_hint = false 🔗

  • void set_tile_scroll_hint(value: bool)

  • bool is_scroll_hint_tiled()

If true, the scroll hint texture will be tiled instead of stretched. See scroll_hint_mode.


ScrollMode vertical_scroll_mode = 1 🔗

Contrôle si la barre de défilement verticale peut être utilisée et quand elle devrait être visible.


Descriptions des méthodes

void ensure_control_visible(control: Control) 🔗

Veille à ce que le control donné soit visible (doit être un enfant direct ou indirect du ScrollContainer). Utilisé par follow_focus.

Note : Cela ne fonctionnera pas sur un nœud qui vient d'être ajouté pendant la même trame. Si vous voulez faire défiler vers un enfant nouvellement ajouté, vous devez attendre jusqu'à la prochaine trame en utilisant SceneTree.process_frame :

add_child(noeud_enfant)
await get_tree().process_frame
ensure_control_visible(noeud_enfant)

HScrollBar get_h_scroll_bar() 🔗

Renvoie la barre de défilement horizontale HScrollBar de ce ScrollContainer.

Attention : Il s'agit d'un nœud interne requis, l'enlever et le libérer peut causer un plantage. Si vous souhaitez désactiver ou cacher une barre de défilement, vous pouvez utiliser horizontal_scroll_mode.


VScrollBar get_v_scroll_bar() 🔗

Renvoie la barre de défilement verticale VScrollBar de ce ScrollContainer.

Attention : Il s'agit d'un nœud interne requis, l'enlever et le libérer peut causer un plantage. Si vous souhaitez désactiver ou cacher une barre de défilement, vous pouvez utiliser vertical_scroll_mode.


Descriptions des propriétés du thème

Color scroll_hint_horizontal_color = Color(0, 0, 0, 1) 🔗

Color used to modulate the scroll_hint_horizontal texture.


Color scroll_hint_vertical_color = Color(0, 0, 0, 1) 🔗

Color used to modulate the scroll_hint_vertical texture.


int scrollbar_h_separation = 0 🔗

The space between the ScrollContainer's vertical scroll bar and its content, in pixels. No space will be added when the content's minimum size is larger than the ScrollContainer's size.


int scrollbar_v_separation = 0 🔗

The space between the ScrollContainer's horizontal scroll bar and its content, in pixels. No space will be added when the content's minimum size is larger than the ScrollContainer's size.


Texture2D scroll_hint_horizontal 🔗

The indicator that will be shown when the content can still be scrolled horizontally. See scroll_hint_mode.


Texture2D scroll_hint_vertical 🔗

The indicator that will be shown when the content can still be scrolled vertically. See scroll_hint_mode.


StyleBox focus 🔗

La StyleBox du bord avec focus du ScrollContainer. Seulement utilisé si draw_focus_border vaut true.


StyleBox panel 🔗

Le StyleBox de l'arrière-plan du ScrollContainer.