Table of Contents

Class TabContainer

Namespace
Godot
Assembly
GodotSharp.dll

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.

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

Constructors

TabContainer()

public TabContainer()

Properties

AllTabsInFront

If true, all tabs are drawn in front of the panel. If false, inactive tabs are drawn behind the panel.

public bool AllTabsInFront { get; set; }

Property Value

bool

ClipTabs

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.

public bool ClipTabs { get; set; }

Property Value

bool

CurrentTab

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.

public int CurrentTab { get; set; }

Property Value

int

DragToRearrangeEnabled

If true, tabs can be rearranged with mouse drag.

public bool DragToRearrangeEnabled { get; set; }

Property Value

bool

TabAlignment

Sets the position at which tabs will be placed. See TabBar.AlignmentMode for details.

public TabBar.AlignmentMode TabAlignment { get; set; }

Property Value

TabBar.AlignmentMode

TabFocusMode

The focus access mode for the internal TabBar node.

public Control.FocusModeEnum TabFocusMode { get; set; }

Property Value

Control.FocusModeEnum

TabsRearrangeGroup

TabContainers with the same rearrange group ID will allow dragging the tabs between them. Enable drag with DragToRearrangeEnabled.

Setting this to -1 will disable rearranging between TabContainers.

public int TabsRearrangeGroup { get; set; }

Property Value

int

TabsVisible

If true, tabs are visible. If false, tabs' content and titles are hidden.

public bool TabsVisible { get; set; }

Property Value

bool

UseHiddenTabsForMinSize

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.

public bool UseHiddenTabsForMinSize { get; set; }

Property Value

bool

Methods

GetCurrentTabControl()

Returns the child Control node located at the active tab index.

public Control GetCurrentTabControl()

Returns

Control

GetPopup()

Returns the Popup node instance if one has been set already with SetPopup(Node).

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 Visible property.

public Popup GetPopup()

Returns

Popup

GetPreviousTab()

Returns the previously active tab index.

public int GetPreviousTab()

Returns

int

GetTabBar()

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.

public TabBar GetTabBar()

Returns

TabBar

GetTabButtonIcon(int)

Returns the button icon from the tab at index tabIdx.

public Texture2D GetTabButtonIcon(int tabIdx)

Parameters

tabIdx int

Returns

Texture2D

GetTabControl(int)

Returns the Control node from the tab at index tabIdx.

public Control GetTabControl(int tabIdx)

Parameters

tabIdx int

Returns

Control

GetTabCount()

Returns the number of tabs.

public int GetTabCount()

Returns

int

GetTabIcon(int)

Returns the Texture2D for the tab at index tabIdx or null if the tab has no Texture2D.

public Texture2D GetTabIcon(int tabIdx)

Parameters

tabIdx int

Returns

Texture2D

GetTabIdxAtPoint(Vector2)

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.

public int GetTabIdxAtPoint(Vector2 point)

Parameters

point Vector2

Returns

int

GetTabIdxFromControl(Control)

Returns the index of the tab tied to the given control. The control must be a child of the TabContainer.

public int GetTabIdxFromControl(Control control)

Parameters

control Control

Returns

int

GetTabMetadata(int)

Returns the metadata value set to the tab at index tabIdx using SetTabMetadata(int, Variant). If no metadata was previously set, returns null by default.

public Variant GetTabMetadata(int tabIdx)

Parameters

tabIdx int

Returns

Variant

GetTabTitle(int)

Returns the title of the tab at index tabIdx. Tab titles default to the name of the indexed child node, but this can be overridden with SetTabTitle(int, string).

public string GetTabTitle(int tabIdx)

Parameters

tabIdx int

Returns

string

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

IsTabDisabled(int)

Returns true if the tab at index tabIdx is disabled.

public bool IsTabDisabled(int tabIdx)

Parameters

tabIdx int

Returns

bool

IsTabHidden(int)

Returns true if the tab at index tabIdx is hidden.

public bool IsTabHidden(int tabIdx)

Parameters

tabIdx int

Returns

bool

SelectNextAvailable()

Selects the first available tab with greater index than the currently selected. Returns true if tab selection changed.

public bool SelectNextAvailable()

Returns

bool

SelectPreviousAvailable()

Selects the first available tab with lower index than the currently selected. Returns true if tab selection changed.

public bool SelectPreviousAvailable()

Returns

bool

SetPopup(Node)

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.

public void SetPopup(Node popup)

Parameters

popup Node

SetTabButtonIcon(int, Texture2D)

Sets the button icon from the tab at index tabIdx.

public void SetTabButtonIcon(int tabIdx, Texture2D icon)

Parameters

tabIdx int
icon Texture2D

SetTabDisabled(int, bool)

If disabled is true, disables the tab at index tabIdx, making it non-interactable.

public void SetTabDisabled(int tabIdx, bool disabled)

Parameters

tabIdx int
disabled bool

SetTabHidden(int, bool)

If hidden is true, hides the tab at index tabIdx, making it disappear from the tab area.

public void SetTabHidden(int tabIdx, bool hidden)

Parameters

tabIdx int
hidden bool

SetTabIcon(int, Texture2D)

Sets an icon for the tab at index tabIdx.

public void SetTabIcon(int tabIdx, Texture2D icon)

Parameters

tabIdx int
icon Texture2D

SetTabMetadata(int, Variant)

Sets the metadata value for the tab at index tabIdx, which can be retrieved later using GetTabMetadata(int).

public void SetTabMetadata(int tabIdx, Variant metadata)

Parameters

tabIdx int
metadata Variant

SetTabTitle(int, string)

Sets a custom title for the tab at index tabIdx (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.

public void SetTabTitle(int tabIdx, string title)

Parameters

tabIdx int
title string

Events

ActiveTabRearranged

Emitted when the active tab is rearranged via mouse drag. See DragToRearrangeEnabled.

public event TabContainer.ActiveTabRearrangedEventHandler ActiveTabRearranged

Event Type

TabContainer.ActiveTabRearrangedEventHandler

PrePopupPressed

Emitted when the TabContainer's Popup button is clicked. See SetPopup(Node) for details.

public event Action PrePopupPressed

Event Type

Action

TabButtonPressed

Emitted when the user clicks on the button icon on this tab.

public event TabContainer.TabButtonPressedEventHandler TabButtonPressed

Event Type

TabContainer.TabButtonPressedEventHandler

TabChanged

Emitted when switching to another tab.

public event TabContainer.TabChangedEventHandler TabChanged

Event Type

TabContainer.TabChangedEventHandler

TabClicked

Emitted when a tab is clicked, even if it is the current tab.

public event TabContainer.TabClickedEventHandler TabClicked

Event Type

TabContainer.TabClickedEventHandler

TabHovered

Emitted when a tab is hovered by the mouse.

public event TabContainer.TabHoveredEventHandler TabHovered

Event Type

TabContainer.TabHoveredEventHandler

TabSelected

Emitted when a tab is selected via click, directional input, or script, even if it is the current tab.

public event TabContainer.TabSelectedEventHandler TabSelected

Event Type

TabContainer.TabSelectedEventHandler