FoldableContainer
Inherits: Container < Control < CanvasItem < Entity < Object
Description
Section titled “Description”A container that can be expanded/collapsed.
A container that can be expanded/collapsed, with a title that can be filled with controls, such as buttons. This is also called an accordion.
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.
A FoldableContainer can be grouped with other FoldableContainers so that only one of them can be opened at a time; see foldable_group and FoldableGroup.
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| Control.FocusMode | focus_mode |
2 (overrides Control) |
| FoldableGroup | foldable_group |
|
| bool | folded |
false |
| String | language |
"" |
| Control.MouseFilter | mouse_filter |
0 (overrides Control) |
| String | title |
"" |
| HorizontalAlignment | title_alignment |
0 |
| TitlePosition | title_position |
0 |
| Control.TextDirection | title_text_direction |
0 |
| TextSystem.OverrunBehavior | title_text_overrun_behavior |
0 |
Methods
Section titled “Methods”| Returns | Method |
|---|---|
| void | add_title_bar_control(control: Control) |
| void | expand() |
| void | fold() |
| Control | get_title_bar_control(index: int) const |
| int | get_title_bar_control_count() const |
| void | remove_title_bar_control(control: Control) |
Signals
Section titled “Signals”folding_changed
folding_changed(is_folded: bool)
Emitted when the container is folded/expanded.
Enumerations
Section titled “Enumerations”TitlePosition
enum TitlePosition
POSITION_TOP = 0
Makes the title appear at the top of the container.
POSITION_BOTTOM = 1
Makes the title appear at the bottom of the container. Also makes all StyleBoxes flipped vertically.
Theme items
Section titled “Theme items”collapsed_font_color
Color collapsed_font_color (color) = Color(1, 1, 1, 1)
font_color
Color font_color (color) = Color(0.875, 0.875, 0.875, 1)
font_outline_color
Color font_outline_color (color) = Color(1, 1, 1, 1)
hover_font_color
Color hover_font_color (color) = Color(0.95, 0.95, 0.95, 1)
h_separation
int h_separation (constant) = 2
icon_max_width
int icon_max_width (constant) = 0
outline_size
int outline_size (constant) = 0
font
Font font (font)
font_size
int font_size (font_size)
expanded_arrow
Texture2D expanded_arrow (icon)
expanded_arrow_mirrored
Texture2D expanded_arrow_mirrored (icon)
folded_arrow
Texture2D folded_arrow (icon)
folded_arrow_mirrored
Texture2D folded_arrow_mirrored (icon)
expanded_sound
AudioStream expanded_sound (sound)
focus_sound
AudioStream focus_sound (sound)
folded_sound
AudioStream folded_sound (sound)
focus
StyleBox focus (style)
panel
StyleBox panel (style)
title_collapsed_hover_panel
StyleBox title_collapsed_hover_panel (style)
title_collapsed_panel
StyleBox title_collapsed_panel (style)
title_hover_panel
StyleBox title_hover_panel (style)
title_panel
StyleBox title_panel (style)
Property descriptions
Section titled “Property descriptions”foldable_group
FoldableGroup foldable_group
The FoldableGroup associated with the container. When multiple FoldableContainer nodes share the same group, only one of them is allowed to be unfolded.
folded
bool folded = false
If true, the container will become folded and will hide all its children.
language
String language = ""
Language code used for text shaping algorithms. If left empty, the current locale is used instead.
title
String title = ""
The container’s title text.
title_alignment
HorizontalAlignment title_alignment = 0
Title’s horizontal text alignment.
title_position
TitlePosition title_position = 0
Title’s position.
title_text_direction
Control.TextDirection title_text_direction = 0
Title text writing direction.
title_text_overrun_behavior
TextSystem.OverrunBehavior title_text_overrun_behavior = 0
Defines the behavior of the title when the text is longer than the available space.
Method descriptions
Section titled “Method descriptions”add_title_bar_control
void add_title_bar_control(control: Control)
Adds a Control that will be placed next to the container’s title, obscuring the clickable area. Prime usage is adding Button nodes, but it can be any Control.
The control will be added as a child of this container and removed from previous parent if necessary. The controls will be placed aligned to the right, with the first added control being the leftmost one.
expand
void expand()
Expands the container and emits folding_changed.
fold
void fold()
Folds the container and emits folding_changed.
get_title_bar_control
Control get_title_bar_control(index: int) const
Returns the title bar Control at the given index, or null if the index is out of bounds.
Use get_title_bar_control_count() to get the total number of title bar controls.
get_title_bar_control_count
int get_title_bar_control_count() const
Returns the number of controls added to the title bar via add_title_bar_control().
remove_title_bar_control
void remove_title_bar_control(control: Control)
Removes a Control added with add_title_bar_control(). The node is not freed automatically, you need to use Entity.queue_destroy().
