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
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
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
DragToRearrangeEnabled
If true
, tabs can be rearranged with mouse drag.
public bool DragToRearrangeEnabled { get; set; }
Property Value
TabAlignment
Sets the position at which tabs will be placed. See TabBar.AlignmentMode for details.
public TabBar.AlignmentMode TabAlignment { get; set; }
Property Value
TabFocusMode
The focus access mode for the internal TabBar node.
public Control.FocusModeEnum TabFocusMode { get; set; }
Property Value
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
TabsVisible
If true
, tabs are visible. If false
, tabs' content and titles are hidden.
public bool TabsVisible { get; set; }
Property Value
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
Methods
GetCurrentTabControl()
Returns the child Control node located at the active tab index.
public Control GetCurrentTabControl()
Returns
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
GetPreviousTab()
Returns the previously active tab index.
public int GetPreviousTab()
Returns
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
GetTabButtonIcon(int)
Returns the button icon from the tab at index tabIdx
.
public Texture2D GetTabButtonIcon(int tabIdx)
Parameters
tabIdx
int
Returns
GetTabControl(int)
Returns the Control node from the tab at index tabIdx
.
public Control GetTabControl(int tabIdx)
Parameters
tabIdx
int
Returns
GetTabCount()
Returns the number of tabs.
public int GetTabCount()
Returns
GetTabIcon(int)
public Texture2D GetTabIcon(int tabIdx)
Parameters
tabIdx
int
Returns
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
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
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
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
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_nameName of the method to check for.
Returns
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_nameName of the signal to check for.
Returns
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_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsTabDisabled(int)
Returns true
if the tab at index tabIdx
is disabled.
public bool IsTabDisabled(int tabIdx)
Parameters
tabIdx
int
Returns
IsTabHidden(int)
Returns true
if the tab at index tabIdx
is hidden.
public bool IsTabHidden(int tabIdx)
Parameters
tabIdx
int
Returns
SelectNextAvailable()
Selects the first available tab with greater index than the currently selected. Returns true
if tab selection changed.
public bool SelectNextAvailable()
Returns
SelectPreviousAvailable()
Selects the first available tab with lower index than the currently selected. Returns true
if tab selection changed.
public bool SelectPreviousAvailable()
Returns
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
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
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
SetTabIcon(int, Texture2D)
Sets an icon for the tab at index tabIdx
.
public void SetTabIcon(int tabIdx, Texture2D icon)
Parameters
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
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
Events
ActiveTabRearranged
Emitted when the active tab is rearranged via mouse drag. See DragToRearrangeEnabled.
public event TabContainer.ActiveTabRearrangedEventHandler ActiveTabRearranged
Event Type
PrePopupPressed
Emitted when the TabContainer's Popup button is clicked. See SetPopup(Node) for details.
public event Action PrePopupPressed
Event Type
TabButtonPressed
Emitted when the user clicks on the button icon on this tab.
public event TabContainer.TabButtonPressedEventHandler TabButtonPressed
Event Type
TabChanged
Emitted when switching to another tab.
public event TabContainer.TabChangedEventHandler TabChanged
Event Type
TabClicked
Emitted when a tab is clicked, even if it is the current tab.
public event TabContainer.TabClickedEventHandler TabClicked
Event Type
TabHovered
Emitted when a tab is hovered by the mouse.
public event TabContainer.TabHoveredEventHandler TabHovered
Event Type
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