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
CurrentTab
Select tab at index tab_idx
.
public int CurrentTab { get; set; }
Property Value
DragToRearrangeEnabled
If true
, tabs can be rearranged with mouse drag.
public bool DragToRearrangeEnabled { get; set; }
Property Value
MaxTabWidth
Sets the maximum width which all tabs should be limited to. Unlimited if set to 0
.
public int MaxTabWidth { get; set; }
Property Value
ScrollToSelected
If true
, the tab offset will be changed to keep the currently selected tab visible.
public bool ScrollToSelected { get; set; }
Property Value
ScrollingEnabled
if true
, the mouse's scroll wheel can be used to navigate the scroll view.
public bool ScrollingEnabled { get; set; }
Property Value
SelectWithRmb
If true
, enables selecting a tab with the right mouse button.
public bool SelectWithRmb { 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
TabCloseDisplayPolicy
Sets when the close button will appear on the tabs. See TabBar.CloseButtonDisplayPolicy for details.
public TabBar.CloseButtonDisplayPolicy TabCloseDisplayPolicy { get; set; }
Property Value
TabCount
The number of tabs currently in the bar.
public int TabCount { get; set; }
Property Value
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
Methods
AddTab(string, Texture2D)
Adds a new tab.
public void AddTab(string title = "", Texture2D icon = null)
Parameters
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
GetPreviousTab()
Returns the previously active tab index.
public int GetPreviousTab()
Returns
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
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
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
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
GetTabLanguage(int)
Returns tab title language code.
public string GetTabLanguage(int tabIdx)
Parameters
tabIdx
int
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
GetTabOffset()
Returns the number of hidden tabs offsetted to the left.
public int GetTabOffset()
Returns
GetTabRect(int)
Returns tab Rect2 with local position and size.
public Rect2 GetTabRect(int tabIdx)
Parameters
tabIdx
int
Returns
GetTabTextDirection(int)
Returns tab title text base writing direction.
public Control.TextDirection GetTabTextDirection(int tabIdx)
Parameters
tabIdx
int
Returns
GetTabTitle(int)
Returns the title of the tab at index tabIdx
.
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
MoveTab(int, int)
Moves a tab from from
to to
.
public void MoveTab(int from, int to)
Parameters
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
SelectPreviousAvailable()
Selects the first available tab with lower index than the currently selected. Returns true
if tab selection changed.
public bool SelectPreviousAvailable()
Returns
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
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
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
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
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
SetTabTextDirection(int, TextDirection)
Sets tab title base writing direction.
public void SetTabTextDirection(int tabIdx, Control.TextDirection direction)
Parameters
tabIdx
intdirection
Control.TextDirection
SetTabTitle(int, string)
Sets a title
for the tab at index tabIdx
.
public void SetTabTitle(int tabIdx, string title)
Parameters
Events
ActiveTabRearranged
Emitted when the active tab is rearranged via mouse drag. See DragToRearrangeEnabled.
public event TabBar.ActiveTabRearrangedEventHandler ActiveTabRearranged
Event Type
TabButtonPressed
Emitted when a tab's right button is pressed. See SetTabButtonIcon(int, Texture2D).
public event TabBar.TabButtonPressedEventHandler TabButtonPressed
Event Type
TabChanged
Emitted when switching to another tab.
public event TabBar.TabChangedEventHandler TabChanged
Event Type
TabClicked
Emitted when a tab is clicked, even if it is the current tab.
public event TabBar.TabClickedEventHandler TabClicked
Event Type
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
TabHovered
Emitted when a tab is hovered by the mouse.
public event TabBar.TabHoveredEventHandler TabHovered
Event Type
TabRmbClicked
Emitted when a tab is right-clicked. SelectWithRmb must be enabled.
public event TabBar.TabRmbClickedEventHandler TabRmbClicked
Event Type
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