Up to date

This page is up to date for Godot 4.3. If you still find outdated information, please open an issue.

FoldableContainerΒΆ

Inherits: Container < Control < CanvasItem < Node < Object

A container that can be expanded/collapsed.

DescriptionΒΆ

A container that can be expanded/collapsed, with a title that can contain buttons.

The title can be positioned at the top or bottom of the container.

The container can be expanded or collapsed by clicking the title or by pressing ui_accept when focused.

Child control nodes are hidden when the container is collapsed. Ignores non-control children.

Can allow grouping with other FoldableContainers, check foldable_group and FoldableGroup.

PropertiesΒΆ

int

button_count

0

FocusMode

focus_mode

2 (overrides Control)

FoldableGroup

foldable_group

bool

folded

false

String

language

""

MouseFilter

mouse_filter

0 (overrides Control)

String

text

""

TextDirection

text_direction

0

OverrunBehavior

text_overrun_behavior

0

HorizontalAlignment

title_alignment

0

TitlePosition

title_position

0

MethodsΒΆ

void

add_button(icon: Texture2D = null, position: int = -1, id: int = -1)

void

clear()

void

expand()

void

fold()

int

get_button_at_position(position: Vector2) const

Texture2D

get_button_icon(index: int) const

int

get_button_id(index: int) const

int

get_button_index(id: int) const

Variant

get_button_metadata(index: int) const

Rect2

get_button_rect(index: int) const

bool

get_button_toggle_mode(index: int) const

String

get_button_tooltip(index: int) const

bool

is_button_auto_hide(index: int) const

bool

is_button_disabled(index: int) const

bool

is_button_toggled(index: int) const

bool

is_button_visible(index: int) const

bool

is_expanded() const

int

move_button(from: int, to: int)

void

remove_button(index: int)

void

set_button_auto_hide(index: int, auto_hide: bool)

void

set_button_disabled(index: int, disabled: bool)

void

set_button_icon(index: int, icon: Texture2D)

void

set_button_id(index: int, id: int)

void

set_button_metadata(index: int, metadata: Variant)

void

set_button_toggle_mode(index: int, enabled: bool)

void

set_button_toggled(index: int, toggled_on: bool)

void

set_button_tooltip(index: int, tooltip: String)

void

set_button_visible(index: int, hidden: bool)

void

set_expanded(expanded: bool)

Theme PropertiesΒΆ

Color

arrow_collapsed_color

Color(0.226, 0.478, 0.921, 1)

Color

arrow_hover_color

Color(0.875, 0.875, 0.875, 1)

Color

arrow_normal_color

Color(0.875, 0.875, 0.875, 0.8)

Color

button_icon_disabled

Color(0.875, 0.875, 0.875, 0.4)

Color

button_icon_hovered

Color(0.875, 0.875, 0.875, 1)

Color

button_icon_normal

Color(0.875, 0.875, 0.875, 0.8)

Color

button_icon_pressed

Color(0.226, 0.478, 0.921, 1)

Color

collapsed_font_color

Color(0.226, 0.478, 0.921, 1)

Color

font_color

Color(0.875, 0.875, 0.875, 0.8)

Color

font_outline_color

Color(0, 0, 0, 1)

Color

hover_font_color

Color(0.875, 0.875, 0.875, 1)

int

h_separation

4

int

outline_size

0

Font

font

int

font_size

Texture2D

expanded_arrow

Texture2D

expanded_arrow_mirrored

Texture2D

folded_arrow

Texture2D

folded_arrow_mirrored

StyleBox

button_disabled_style

StyleBox

button_hovered_style

StyleBox

button_normal_style

StyleBox

button_pressed_style

StyleBox

focus

StyleBox

panel

StyleBox

title_collapsed_hover_panel

StyleBox

title_collapsed_panel

StyleBox

title_hover_panel

StyleBox

title_panel


SignalsΒΆ

button_pressed(index: int) πŸ”—

Emitted when a button is pressed.


button_toggled(toggled_on: bool, index: int) πŸ”—

Emitted when a button is toggled.


folding_changed(is_folded: bool) πŸ”—

Emitted when the container is folded/expanded.


EnumerationsΒΆ

enum TitlePosition: πŸ”—

TitlePosition POSITION_TOP = 0

Make the title appear at the top of the container.

TitlePosition POSITION_BOTTOM = 1

Make the title appear at the bottom of the container.


Property DescriptionsΒΆ

int button_count = 0 πŸ”—

  • void set_button_count(value: int)

  • int get_button_count()

The title buttons count, changing this will change the buttons array size which can add/remove buttons automatically.


FoldableGroup foldable_group πŸ”—

The FoldableGroup associated with the container.


bool folded = false πŸ”—

  • void set_folded(value: bool)

  • bool is_folded()

If true, the container will becomes folded and will hide all it's children.


String language = "" πŸ”—

Language code used for text shaping algorithms. If left empty, current locale is used instead.


String text = "" πŸ”—

The Container's title text.


TextDirection text_direction = 0 πŸ”—

Base text writing direction.


OverrunBehavior text_overrun_behavior = 0 πŸ”—

Defines the behavior of the FoldableContainer when the text is longer than the available space.


HorizontalAlignment title_alignment = 0 πŸ”—

Title's horizontal text alignment as defined in the HorizontalAlignment enum.


TitlePosition title_position = 0 πŸ”—

Title's position as defined in the TitlePosition enum.


Method DescriptionsΒΆ

void add_button(icon: Texture2D = null, position: int = -1, id: int = -1) πŸ”—

Adds a button to the title.


void clear() πŸ”—

Remove all the title buttons.


void expand() πŸ”—

Expands the container and emits folding_changed.


void fold() πŸ”—

Folds the container and emits folding_changed.


int get_button_at_position(position: Vector2) const πŸ”—

Returns the button's index if the given position is inisde the button's rect. Returns -1 if no button was found at this position.


Texture2D get_button_icon(index: int) const πŸ”—

Returns the icon of the button at the given index.


int get_button_id(index: int) const πŸ”—

Returns the ID of the button at the given index.


int get_button_index(id: int) const πŸ”—

Returns the index of the button with the given ID.


Variant get_button_metadata(index: int) const πŸ”—

Returns the metadata for the button at the given index.


Rect2 get_button_rect(index: int) const πŸ”—

Returns the Rect2 which represents the position and size of the button.


bool get_button_toggle_mode(index: int) const πŸ”—

Returns whether the button at the given index is a toggle button.


String get_button_tooltip(index: int) const πŸ”—

Returns the tooltip for the button at the given index.


bool is_button_auto_hide(index: int) const πŸ”—

Returns true if the button at the given index hides when the container is folded otherwise returns false.


bool is_button_disabled(index: int) const πŸ”—

Returns whether the button at the given index is disabled.


bool is_button_toggled(index: int) const πŸ”—

Returns whether the button at the given index is toggled on/off.


bool is_button_visible(index: int) const πŸ”—

Returns whether the button is visible/hidden.


bool is_expanded() const πŸ”—

Returns whether the container is expanded/folded.


int move_button(from: int, to: int) πŸ”—

Changes the button's index.


void remove_button(index: int) πŸ”—

Removes the button at the given index.


void set_button_auto_hide(index: int, auto_hide: bool) πŸ”—

If true, the button at the given index hides when the container is folded.


void set_button_disabled(index: int, disabled: bool) πŸ”—

Disables the button at the given index.


void set_button_icon(index: int, icon: Texture2D) πŸ”—

Changes the icon of the button at the given index.


void set_button_id(index: int, id: int) πŸ”—

Changes the ID of the button at the given index.


void set_button_metadata(index: int, metadata: Variant) πŸ”—

Set the metadata for the button at the given index.


void set_button_toggle_mode(index: int, enabled: bool) πŸ”—

Set the button at the given index to be a toggle button.


void set_button_toggled(index: int, toggled_on: bool) πŸ”—

Set the button at the given index as toggled on/off.


void set_button_tooltip(index: int, tooltip: String) πŸ”—

Sets the tooltip for the button at the given index.


void set_button_visible(index: int, hidden: bool) πŸ”—

Toggles the visibility of the button at the given index.


void set_expanded(expanded: bool) πŸ”—

If true, the container will becomes expanded and will show all it's children.

See also folded.


Theme Property DescriptionsΒΆ

Color arrow_collapsed_color = Color(0.226, 0.478, 0.921, 1) πŸ”—

The arrow's icon color when collapsed.


Color arrow_hover_color = Color(0.875, 0.875, 0.875, 1) πŸ”—

The arrow's icon color when hovered and expanded.


Color arrow_normal_color = Color(0.875, 0.875, 0.875, 0.8) πŸ”—

The arrow's icon color expanded.


Color button_icon_disabled = Color(0.875, 0.875, 0.875, 0.4) πŸ”—

The title's icon color when disabled.


Color button_icon_hovered = Color(0.875, 0.875, 0.875, 1) πŸ”—

The title's icon color when hovered.


Color button_icon_normal = Color(0.875, 0.875, 0.875, 0.8) πŸ”—

The title's icon color when normal.


Color button_icon_pressed = Color(0.226, 0.478, 0.921, 1) πŸ”—

The title's icon color when pressed.


Color collapsed_font_color = Color(0.226, 0.478, 0.921, 1) πŸ”—

The title's font color when collapsed.


Color font_color = Color(0.875, 0.875, 0.875, 0.8) πŸ”—

The title's font color when expanded.


Color font_outline_color = Color(0, 0, 0, 1) πŸ”—

The title's font outline color.


Color hover_font_color = Color(0.875, 0.875, 0.875, 1) πŸ”—

The title's font hover color.


int h_separation = 4 πŸ”—

The horizontal separation between the title's icon and text.


int outline_size = 0 πŸ”—

The title's font outline size.


Font font πŸ”—

The title's font.


int font_size πŸ”—

The title's font size.


Texture2D expanded_arrow πŸ”—

The title's icon used when expanded.


Texture2D expanded_arrow_mirrored πŸ”—

The title's icon used when expanded (for bottom title).


Texture2D folded_arrow πŸ”—

The title's icon used when folded (for left-to-right layouts).


Texture2D folded_arrow_mirrored πŸ”—

The title's icon used when collapsed (for right-to-left layouts).


StyleBox button_disabled_style πŸ”—

The title's button disabled style.


StyleBox button_hovered_style πŸ”—

The title's button hover style.


StyleBox button_normal_style πŸ”—

The title's button normal style.


StyleBox button_pressed_style πŸ”—

The title's button pressed style.


StyleBox focus πŸ”—

Background used when FoldableContainer has GUI focus. The focus StyleBox is displayed over the base StyleBox, so a partially transparent StyleBox should be used to ensure the base StyleBox remains visible. A StyleBox that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a StyleBoxEmpty resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.


StyleBox panel πŸ”—

Default background for the FoldableContainer.


StyleBox title_collapsed_hover_panel πŸ”—

Background used when the mouse cursor enters the title's area when collapsed.


StyleBox title_collapsed_panel πŸ”—

Default background for the FoldableContainer's title when collapsed.


StyleBox title_hover_panel πŸ”—

Background used when the mouse cursor enters the title's area when expanded.


StyleBox title_panel πŸ”—

Default background for the FoldableContainer's title when expanded.