Table of Contents

Class TabBar

Namespace
Godot
Assembly
GodotSharp.dll

A control that provides a horizontal bar with tabs. Similar to TabContainer but is only in charge of drawing tabs, not interacting with children.

public class TabBar : Control, IDisposable
Inheritance
TabBar
Implements
Inherited Members

Constructors

TabBar()

public TabBar()

Properties

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

Select tab at index tab_idx.

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

MaxTabWidth

Sets the maximum width which all tabs should be limited to. Unlimited if set to 0.

public int MaxTabWidth { get; set; }

Property Value

int

ScrollToSelected

If true, the tab offset will be changed to keep the currently selected tab visible.

public bool ScrollToSelected { get; set; }

Property Value

bool

ScrollingEnabled

if true, the mouse's scroll wheel can be used to navigate the scroll view.

public bool ScrollingEnabled { get; set; }

Property Value

bool

SelectWithRmb

If true, enables selecting a tab with the right mouse button.

public bool SelectWithRmb { 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

TabCloseDisplayPolicy

Sets when the close button will appear on the tabs. See TabBar.CloseButtonDisplayPolicy for details.

public TabBar.CloseButtonDisplayPolicy TabCloseDisplayPolicy { get; set; }

Property Value

TabBar.CloseButtonDisplayPolicy

TabCount

The number of tabs currently in the bar.

public int TabCount { get; set; }

Property Value

int

TabsRearrangeGroup

TabBars 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 TabBars.

public int TabsRearrangeGroup { get; set; }

Property Value

int

Methods

AddTab(string, Texture2D)

Adds a new tab.

public void AddTab(string title = "", Texture2D icon = null)

Parameters

title string
icon Texture2D

ClearTabs()

Clears all tabs.

public void ClearTabs()

EnsureTabVisible(int)

Moves the scroll view to make the tab visible.

public void EnsureTabVisible(int idx)

Parameters

idx int

GetOffsetButtonsVisible()

Returns true if the offset buttons (the ones that appear when there's not enough space for all tabs) are visible.

public bool GetOffsetButtonsVisible()

Returns

bool

GetPreviousTab()

Returns the previously active tab index.

public int GetPreviousTab()

Returns

int

GetTabButtonIcon(int)

Returns the icon for the right button of the tab at index tabIdx or null if the right button has no icon.

public Texture2D GetTabButtonIcon(int tabIdx)

Parameters

tabIdx int

Returns

Texture2D

GetTabIcon(int)

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

public Texture2D GetTabIcon(int tabIdx)

Parameters

tabIdx int

Returns

Texture2D

GetTabIconMaxWidth(int)

Returns the maximum allowed width of the icon for the tab at index tabIdx.

public int GetTabIconMaxWidth(int tabIdx)

Parameters

tabIdx int

Returns

int

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

GetTabLanguage(int)

Returns tab title language code.

public string GetTabLanguage(int tabIdx)

Parameters

tabIdx int

Returns

string

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

GetTabOffset()

Returns the number of hidden tabs offsetted to the left.

public int GetTabOffset()

Returns

int

GetTabRect(int)

Returns tab Rect2 with local position and size.

public Rect2 GetTabRect(int tabIdx)

Parameters

tabIdx int

Returns

Rect2

GetTabTextDirection(int)

Returns tab title text base writing direction.

public Control.TextDirection GetTabTextDirection(int tabIdx)

Parameters

tabIdx int

Returns

Control.TextDirection

GetTabTitle(int)

Returns the title of the tab at index tabIdx.

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

MoveTab(int, int)

Moves a tab from from to to.

public void MoveTab(int from, int to)

Parameters

from int
to int

RemoveTab(int)

Removes the tab at index tabIdx.

public void RemoveTab(int tabIdx)

Parameters

tabIdx int

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

SetTabButtonIcon(int, Texture2D)

Sets an icon for the button of the tab at index tabIdx (located to the right, before the close button), making it visible and clickable (See TabButtonPressed). Giving it a null value will hide the button.

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

SetTabIconMaxWidth(int, int)

Sets the maximum allowed width of the icon for the tab at index tabIdx. 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.

public void SetTabIconMaxWidth(int tabIdx, int width)

Parameters

tabIdx int
width int

SetTabLanguage(int, string)

Sets language code of tab title used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

public void SetTabLanguage(int tabIdx, string language)

Parameters

tabIdx int
language string

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

SetTabTextDirection(int, TextDirection)

Sets tab title base writing direction.

public void SetTabTextDirection(int tabIdx, Control.TextDirection direction)

Parameters

tabIdx int
direction Control.TextDirection

SetTabTitle(int, string)

Sets a title for the tab at index tabIdx.

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 TabBar.ActiveTabRearrangedEventHandler ActiveTabRearranged

Event Type

TabBar.ActiveTabRearrangedEventHandler

TabButtonPressed

Emitted when a tab's right button is pressed. See SetTabButtonIcon(int, Texture2D).

public event TabBar.TabButtonPressedEventHandler TabButtonPressed

Event Type

TabBar.TabButtonPressedEventHandler

TabChanged

Emitted when switching to another tab.

public event TabBar.TabChangedEventHandler TabChanged

Event Type

TabBar.TabChangedEventHandler

TabClicked

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

public event TabBar.TabClickedEventHandler TabClicked

Event Type

TabBar.TabClickedEventHandler

TabClosePressed

Emitted when a tab's close button is pressed.

Note: Tabs are not removed automatically once the close button is pressed, this behavior needs to be programmed manually. For example:

GetNode<TabBar>("TabBar").TabClosePressed += GetNode<TabBar>("TabBar").RemoveTab;
public event TabBar.TabClosePressedEventHandler TabClosePressed

Event Type

TabBar.TabClosePressedEventHandler

TabHovered

Emitted when a tab is hovered by the mouse.

public event TabBar.TabHoveredEventHandler TabHovered

Event Type

TabBar.TabHoveredEventHandler

TabRmbClicked

Emitted when a tab is right-clicked. SelectWithRmb must be enabled.

public event TabBar.TabRmbClickedEventHandler TabRmbClicked

Event Type

TabBar.TabRmbClickedEventHandler

TabSelected

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

public event TabBar.TabSelectedEventHandler TabSelected

Event Type

TabBar.TabSelectedEventHandler