TabContainer
Inherits: Container < Control < CanvasItem < Entity < Object
Description
Section titled “Description”A container that creates a tab for each child control, displaying only the active tab’s control.
Arranges child controls into a tabbed view, creating a tab for each one. The active tab’s corresponding control is made visible, while all other child controls are hidden. Ignores non-control children.
Note: The drawing of the clickable tabs is handled by this node; TabBar is not needed.
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| bool | clip_tabs |
true |
| int | current_tab |
-1 |
| bool | deselect_enabled |
false |
| bool | drag_to_rearrange_enabled |
false |
| bool | switch_on_drag_hover |
true |
| TabBar.AlignmentMode | tab_alignment |
0 |
| Control.FocusMode | tab_focus_mode |
2 |
| TabBar.SizingMode | tab_sizing |
0 |
| bool | tab_{index}/disabled |
false |
| bool | tab_{index}/hidden |
false |
| Texture2D | tab_{index}/icon |
|
| String | tab_{index}/title |
"" |
| TabPosition | tabs_position |
0 |
| int | tabs_rearrange_group |
-1 |
| bool | tabs_visible |
true |
| bool | use_hidden_tabs_for_min_size |
false |
Methods
Section titled “Methods”Signals
Section titled “Signals”active_tab_rearranged
active_tab_rearranged(idx_to: int)
Emitted when the active tab is rearranged via mouse drag. See drag_to_rearrange_enabled.
pre_popup_pressed
pre_popup_pressed()
Emitted when the TabContainer’s Popup button is clicked. See set_popup() for details.
tab_button_pressed
tab_button_pressed(tab: int)
Emitted when the user clicks on the button icon on this tab.
tab_changed
tab_changed(tab: int)
Emitted when switching to another tab.
tab_clicked
tab_clicked(tab: int)
Emitted when a tab is clicked, even if it is the current tab.
tab_hovered
tab_hovered(tab: int)
Emitted when a tab is hovered by the mouse.
tab_selected
tab_selected(tab: int)
Emitted when a tab is selected via click, directional input, or script, even if it is the current tab.
Enumerations
Section titled “Enumerations”TabPosition
enum TabPosition
POSITION_TOP = 0
Places the tab bar at the top.
POSITION_BOTTOM = 1
Places the tab bar at the bottom. The tab bar’s StyleBox will be flipped vertically.
POSITION_MAX = 2
Represents the size of the TabPosition enum.
Theme items
Section titled “Theme items”drop_mark_color
Color drop_mark_color (color) = Color(1, 1, 1, 1)
font_disabled_color
Color font_disabled_color (color) = Color(0.875, 0.875, 0.875, 0.5)
font_hovered_color
Color font_hovered_color (color) = Color(0.95, 0.95, 0.95, 1)
font_outline_color
Color font_outline_color (color) = Color(0, 0, 0, 1)
font_selected_color
Color font_selected_color (color) = Color(0.95, 0.95, 0.95, 1)
font_unselected_color
Color font_unselected_color (color) = Color(0.7, 0.7, 0.7, 1)
icon_disabled_color
Color icon_disabled_color (color) = Color(1, 1, 1, 1)
icon_hovered_color
Color icon_hovered_color (color) = Color(1, 1, 1, 1)
icon_selected_color
Color icon_selected_color (color) = Color(1, 1, 1, 1)
icon_unselected_color
Color icon_unselected_color (color) = Color(1, 1, 1, 1)
icon_max_width
int icon_max_width (constant) = 0
icon_separation
int icon_separation (constant) = 4
outline_size
int outline_size (constant) = 0
side_margin
int side_margin (constant) = 8
tab_separation
int tab_separation (constant) = 0
font
Font font (font)
font_size
int font_size (font_size)
decrement
Texture2D decrement (icon)
decrement_highlight
Texture2D decrement_highlight (icon)
drop_mark
Texture2D drop_mark (icon)
increment
Texture2D increment (icon)
increment_highlight
Texture2D increment_highlight (icon)
menu
Texture2D menu (icon)
menu_highlight
Texture2D menu_highlight (icon)
drag_ended_sound
AudioStream drag_ended_sound (sound)
drag_started_sound
AudioStream drag_started_sound (sound)
focus_sound
AudioStream focus_sound (sound)
hover_sound
AudioStream hover_sound (sound)
pressed_disabled_sound
AudioStream pressed_disabled_sound (sound)
pressed_sound
AudioStream pressed_sound (sound)
panel
StyleBox panel (style)
tab_disabled
StyleBox tab_disabled (style)
tab_focus
StyleBox tab_focus (style)
tab_hovered
StyleBox tab_hovered (style)
tab_selected
StyleBox tab_selected (style)
tab_unselected
StyleBox tab_unselected (style)
tabbar_background
StyleBox tabbar_background (style)
Property descriptions
Section titled “Property descriptions”clip_tabs
bool clip_tabs = true
If true, tabs overflowing this node’s width will be hidden, displaying two navigation buttons instead. Otherwise, this node’s minimum size is updated so that all tabs are visible.
current_tab
int current_tab = -1
The current tab index. When set, this index’s Control node’s visible property is set to true and all others are set to false.
A value of -1 means that no tab is selected.
deselect_enabled
bool deselect_enabled = false
If true, all tabs can be deselected so that no tab is selected. Click on the current_tab to deselect it.
Only the tab header will be shown if no tabs are selected.
drag_to_rearrange_enabled
bool drag_to_rearrange_enabled = false
If true, tabs can be rearranged with mouse drag.
switch_on_drag_hover
bool switch_on_drag_hover = true
If true, hovering over a tab while dragging something will switch to that tab. Does not have effect when hovering another tab to rearrange.
tab_alignment
TabBar.AlignmentMode tab_alignment = 0
The position at which tabs will be placed.
tab_focus_mode
Control.FocusMode tab_focus_mode = 2
The focus access mode for the internal TabBar node.
tab_sizing
TabBar.SizingMode tab_sizing = 0
The sizing strategy used to determine tab widths.
tab_{index}/disabled
bool tab_{index}/disabled = false
If true, the tab at index is disabled.
Note: index is a value in the 0 .. get_tab_count() - 1 range.
tab_{index}/hidden
bool tab_{index}/hidden = false
If true, the tab at index is hidden.
Note: index is a value in the 0 .. get_tab_count() - 1 range.
tab_{index}/icon
Texture2D tab_{index}/icon
The title text of the tab at index.
Note: index is a value in the 0 .. get_tab_count() - 1 range.
tab_{index}/title
String tab_{index}/title = ""
The tooltip text of the tab at index.
Note: index is a value in the 0 .. get_tab_count() - 1 range.
tabs_position
TabPosition tabs_position = 0
The horizontal alignment of the tabs.
tabs_rearrange_group
int tabs_rearrange_group = -1
TabContainers with the same rearrange group ID will allow dragging the tabs between them. Enable drag with drag_to_rearrange_enabled.
Setting this to -1 will disable rearranging between TabContainers.
tabs_visible
bool tabs_visible = true
If true, tabs are visible. If false, tabs’ content and titles are hidden.
use_hidden_tabs_for_min_size
bool use_hidden_tabs_for_min_size = false
If true, child Control nodes that are hidden have their minimum size take into account in the total, instead of only the currently visible one.
Method descriptions
Section titled “Method descriptions”get_current_tab_control
Control get_current_tab_control() const
Returns the child Control node located at the active tab index.
get_popup
Popup get_popup() const
Returns the Popup node instance if one has been set already with set_popup().
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their Window.visible property.
get_previous_tab
int get_previous_tab() const
Returns the previously active tab index.
get_tab_bar
TabBar get_tab_bar() const
Returns the TabBar contained in this container.
Warning: This is a required internal node, removing and freeing it or editing its tabs may cause a crash. If you wish to edit the tabs, use the methods provided in TabContainer.
get_tab_button_icon
Texture2D get_tab_button_icon(tab_idx: int) const
Returns the button icon from the tab at index tab_idx.
get_tab_control
Control get_tab_control(tab_idx: int) const
Returns the Control node from the tab at index tab_idx.
get_tab_count
int get_tab_count() const
Returns the number of tabs.
get_tab_icon
Texture2D get_tab_icon(tab_idx: int) const
Returns the Texture2D for the tab at index tab_idx or null if the tab has no Texture2D.
get_tab_icon_max_width
int get_tab_icon_max_width(tab_idx: int) const
Returns the maximum allowed width of the icon for the tab at index tab_idx.
get_tab_idx_at_point
int get_tab_idx_at_point(point: Vector2) const
Returns the index of the tab at local coordinates point. Returns -1 if the point is outside the control boundaries or if there’s no tab at the queried position.
get_tab_idx_from_control
int get_tab_idx_from_control(control: Control) const
Returns the index of the tab tied to the given control. The control must be a child of the TabContainer.
get_tab_metadata
Variant get_tab_metadata(tab_idx: int) const
Returns the metadata value set to the tab at index tab_idx using set_tab_metadata(). If no metadata was previously set, returns null by default.
get_tab_title
String get_tab_title(tab_idx: int) const
Returns the title of the tab at index tab_idx. Tab titles default to the name of the indexed child node, but this can be overridden with set_tab_title().
get_tab_tooltip
String get_tab_tooltip(tab_idx: int) const
Returns the tooltip text of the tab at index tab_idx.
is_tab_disabled
bool is_tab_disabled(tab_idx: int) const
Returns true if the tab at index tab_idx is disabled.
is_tab_hidden
bool is_tab_hidden(tab_idx: int) const
Returns true if the tab at index tab_idx is hidden.
select_next_available
bool select_next_available()
Selects the first available tab with greater index than the currently selected. Returns true if tab selection changed.
select_previous_available
bool select_previous_available()
Selects the first available tab with lower index than the currently selected. Returns true if tab selection changed.
set_popup
void set_popup(popup: Entity)
If set on a Popup node instance, a popup menu icon appears in the top-right corner of the TabContainer (setting it to null will make it go away). Clicking it will expand the Popup node.
set_tab_button_icon
void set_tab_button_icon(tab_idx: int, icon: Texture2D)
Sets the button icon from the tab at index tab_idx.
set_tab_disabled
void set_tab_disabled(tab_idx: int, disabled: bool)
If disabled is true, disables the tab at index tab_idx, making it non-interactable.
set_tab_hidden
void set_tab_hidden(tab_idx: int, hidden: bool)
If hidden is true, hides the tab at index tab_idx, making it disappear from the tab area.
set_tab_icon
void set_tab_icon(tab_idx: int, icon: Texture2D)
Sets an icon for the tab at index tab_idx.
set_tab_icon_max_width
void set_tab_icon_max_width(tab_idx: int, width: int)
Sets the maximum allowed width of the icon for the tab at index tab_idx. This limit is applied on top of the default size of the icon and on top of icon_max_width. The height is adjusted according to the icon’s ratio.
set_tab_metadata
void set_tab_metadata(tab_idx: int, metadata: Variant)
Sets the metadata value for the tab at index tab_idx, which can be retrieved later using get_tab_metadata().
set_tab_title
void set_tab_title(tab_idx: int, title: String)
Sets a custom title for the tab at index tab_idx (tab titles default to the name of the indexed child node). Set it back to the child’s name to make the tab default to it again.
set_tab_tooltip
void set_tab_tooltip(tab_idx: int, tooltip: String)
Sets a custom tooltip text for tab at index tab_idx.
Note: By default, if the tooltip is empty and the tab text is truncated (not all characters fit into the tab), the title will be displayed as a tooltip. To hide the tooltip, assign " " as the tooltip text.
