Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AnimationMixer (2)
- AudioStreamPlayer
- CanvasItem (2)
- CanvasLayer (1)
- EditorFileSystem
- EditorPlugin (1)
- EditorResourcePreview
- HTTPRequest
- InstancePlaceholder
- MissingNode
- MultiplayerSpawner
- MultiplayerSynchronizer
- NavigationAgent2D
- NavigationAgent3D
- Node3D (31)
- ResourcePreloader
- ShaderGlobalsOverride
- StatusIndicator
- Timer
- Viewport (2)
- WorldEnvironment
- BaseButton (3)
- ColorRect
- Container (13)
- GraphEdit
- ItemList
- Label
- LineEdit
- MenuBar
- NinePatchRect
- Panel
- Range (6)
- ReferenceRect
- RichTextLabel
- Separator (2)
- TabBar
- TextEdit (1)
- TextureRect
- Tree
- VideoStreamPlayer
Table of contents
-
var clip_tabs: bool = true -
var current_tab: int = -1 -
var deselect_enabled: bool = false -
var drag_to_rearrange_enabled: bool = false -
var focus_mode = FOCUS_ALL -
var max_tab_width: int = 0 -
var scroll_to_selected: bool = true -
var scrolling_enabled: bool = true -
var select_with_rmb: bool = false -
var tab_alignment = ALIGNMENT_LEFT -
var tab_close_display_policy = CLOSE_BUTTON_SHOW_NEVER -
var tab_count: int = 0 -
var tabs_rearrange_group: int = -1 -
func add_tab(icon: Texture2D = null) -> void -
func clear_tabs() -> void -
func ensure_tab_visible(idx: int) -> void -
const func get_offset_buttons_visible() -> bool -
const func get_previous_tab() -> int -
const func get_tab_button_icon(tab_idx: int) -> Texture2D -
const func get_tab_icon(tab_idx: int) -> Texture2D -
const func get_tab_icon_max_width(tab_idx: int) -> int -
const func get_tab_idx_at_point(point: Vector2) -> int -
const func get_tab_language(tab_idx: int) -> String -
const func get_tab_metadata(tab_idx: int) -> Variant -
const func get_tab_offset() -> int -
const func get_tab_rect(tab_idx: int) -> Rect2 -
const func get_tab_text_direction(tab_idx: int) -> intControl.TextDirection -
const func get_tab_title(tab_idx: int) -> String -
const func get_tab_tooltip(tab_idx: int) -> String -
const func is_tab_disabled(tab_idx: int) -> bool -
const func is_tab_hidden(tab_idx: int) -> bool -
func move_tab(to: int) -> void -
func remove_tab(tab_idx: int) -> void -
func select_next_available() -> bool -
func select_previous_available() -> bool -
func set_tab_button_icon(icon: Texture2D) -> void -
func set_tab_disabled(disabled: bool) -> void -
func set_tab_hidden(hidden: bool) -> void -
func set_tab_icon(icon: Texture2D) -> void -
func set_tab_icon_max_width(width: int) -> void -
func set_tab_language(language: String) -> void -
func set_tab_metadata(metadata: Variant) -> void -
func set_tab_text_direction(direction: int enumControl.TextDirection) -> void -
func set_tab_title(title: String) -> void -
func set_tab_tooltip(tooltip: String) -> void -
const ALIGNMENT_LEFT = 0 enum AlignmentMode -
const ALIGNMENT_CENTER = 1 enum AlignmentMode -
const ALIGNMENT_RIGHT = 2 enum AlignmentMode -
const ALIGNMENT_MAX = 3 enum AlignmentMode -
const CLOSE_BUTTON_SHOW_NEVER = 0 enum CloseButtonDisplayPolicy -
const CLOSE_BUTTON_SHOW_ACTIVE_ONLY = 1 enum CloseButtonDisplayPolicy -
const CLOSE_BUTTON_SHOW_ALWAYS = 2 enum CloseButtonDisplayPolicy -
const CLOSE_BUTTON_MAX = 3 enum CloseButtonDisplayPolicy -
enum AlignmentMode -
enum CloseButtonDisplayPolicy -
signal active_tab_rearranged(idx_to: int) -
signal tab_button_pressed(tab: int) -
signal tab_changed(tab: int) -
signal tab_clicked(tab: int) -
signal tab_close_pressed(tab: int) -
signal tab_hovered(tab: int) -
signal tab_rmb_clicked(tab: int) -
signal tab_selected(tab: int) -
self["theme_override_colors/drop_mark_color"] = Color(1, 1, 1, 1) as Color -
self["theme_override_colors/font_disabled_color"] = Color(0.875, 0.875, 0.875, 0.5) as Color -
self["theme_override_colors/font_hovered_color"] = Color(0.95, 0.95, 0.95, 1) as Color -
self["theme_override_colors/font_outline_color"] = Color(0, 0, 0, 1) as Color -
self["theme_override_colors/font_selected_color"] = Color(0.95, 0.95, 0.95, 1) as Color -
self["theme_override_colors/font_unselected_color"] = Color(0.7, 0.7, 0.7, 1) as Color -
self["theme_override_constants/h_separation"] = 4 as int -
self["theme_override_constants/icon_max_width"] = 0 as int -
self["theme_override_constants/outline_size"] = 0 as int -
self["theme_override_fonts/font"] = font as Font -
self["theme_override_font_sizes/font_size"] = font_size as int -
self["theme_override_icons/close"] = icon as Texture2D -
self["theme_override_icons/decrement"] = icon as Texture2D -
self["theme_override_icons/decrement_highlight"] = icon as Texture2D -
self["theme_override_icons/drop_mark"] = icon as Texture2D -
self["theme_override_icons/increment"] = icon as Texture2D -
self["theme_override_icons/increment_highlight"] = icon as Texture2D -
self["theme_override_styles/button_highlight"] = style as StyleBox -
self["theme_override_styles/button_pressed"] = style as StyleBox -
self["theme_override_styles/tab_disabled"] = style as StyleBox -
self["theme_override_styles/tab_focus"] = style as StyleBox -
self["theme_override_styles/tab_hovered"] = style as StyleBox -
self["theme_override_styles/tab_selected"] = style as StyleBox -
self["theme_override_styles/tab_unselected"] = style as StyleBox
TabBar #
is_instantiable, Node, core, not_builtin_classes
A control that provides a horizontal bar with tabs.
A control that provides a horizontal bar with tabs. Similar to TabContainer but is only in charge of drawing tabs, not interacting with children.
Members #
var clip_tabs: bool = 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.
var current_tab: int = -1#
The index of the current selected tab. A value of -1 means that no tab is selected and can only be set when deselect_enabled is true or if all tabs are hidden or disabled.
var deselect_enabled: bool = false#
If true, all tabs can be deselected so that no tab is selected. Click on the current tab to deselect it.
var drag_to_rearrange_enabled: bool = false#
If true, tabs can be rearranged with mouse drag.
var focus_mode = FOCUS_ALL#
var max_tab_width: int = 0#
Sets the maximum width which all tabs should be limited to. Unlimited if set to 0.
var scroll_to_selected: bool = true#
If true, the tab offset will be changed to keep the currently selected tab visible.
var scrolling_enabled: bool = true#
if true, the mouse's scroll wheel can be used to navigate the scroll view.
var select_with_rmb: bool = false#
If true, enables selecting a tab with the right mouse button.
var tab_alignment = ALIGNMENT_LEFT#
Sets the position at which tabs will be placed. See AlignmentMode for details.
var tab_close_display_policy = CLOSE_BUTTON_SHOW_NEVER#
Sets when the close button will appear on the tabs. See CloseButtonDisplayPolicy for details.
var tab_count: int = 0#
The number of tabs currently in the bar.
var tabs_rearrange_group: int = -1#
TabBars 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 TabBars.
Methods #
func add_tab(icon: Texture2D = null) -> void#
Adds a new tab.
func clear_tabs() -> void#
Clears all tabs.
func ensure_tab_visible(idx: int) -> void#
Moves the scroll view to make the tab visible.
const func get_offset_buttons_visible() -> bool#
Returns true if the offset buttons (the ones that appear when there's not enough space for all tabs) are visible.
const func get_previous_tab() -> int#
Returns the previously active tab index.
const func get_tab_button_icon(tab_idx: int) -> Texture2D#
Returns the icon for the right button of the tab at index tab_idx or null if the right button has no icon.
const func get_tab_icon(tab_idx: int) -> Texture2D#
Returns the icon for the tab at index tab_idx or null if the tab has no icon.
const func get_tab_icon_max_width(tab_idx: int) -> int#
Returns the maximum allowed width of the icon for the tab at index tab_idx.
const func get_tab_idx_at_point(point: Vector2) -> int#
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.
const func get_tab_language(tab_idx: int) -> String#
Returns tab title language code.
const func get_tab_metadata(tab_idx: int) -> Variant#
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.
const func get_tab_offset() -> int#
Returns the number of hidden tabs offsetted to the left.
const func get_tab_text_direction(tab_idx: int) -> intControl.TextDirection#
Returns tab title text base writing direction.
const func get_tab_title(tab_idx: int) -> String#
Returns the title of the tab at index tab_idx.
const func get_tab_tooltip(tab_idx: int) -> String#
Returns the tooltip text of the tab at index tab_idx.
const func is_tab_disabled(tab_idx: int) -> bool#
Returns true if the tab at index tab_idx is disabled.
const func is_tab_hidden(tab_idx: int) -> bool#
Returns true if the tab at index tab_idx is hidden.
func move_tab(to: int) -> void#
Moves a tab from from to to.
func remove_tab(tab_idx: int) -> void#
Removes the tab at index tab_idx.
func select_next_available() -> bool#
Selects the first available tab with greater index than the currently selected. Returns true if tab selection changed.
func select_previous_available() -> bool#
Selects the first available tab with lower index than the currently selected. Returns true if tab selection changed.
func set_tab_button_icon(icon: Texture2D) -> void#
Sets an icon for the button of the tab at index tab_idx (located to the right, before the close button), making it visible and clickable (See tab_button_pressed). Giving it a null value will hide the button.
func set_tab_disabled(disabled: bool) -> void#
If disabled is true, disables the tab at index tab_idx, making it non-interactable.
func set_tab_hidden(hidden: bool) -> void#
If hidden is true, hides the tab at index tab_idx, making it disappear from the tab area.
func set_tab_icon(icon: Texture2D) -> void#
Sets an icon for the tab at index tab_idx.
func set_tab_icon_max_width(width: int) -> void#
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.
func set_tab_language(language: String) -> void#
Sets language code of tab title used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
func set_tab_metadata(metadata: Variant) -> void#
Sets the metadata value for the tab at index tab_idx, which can be retrieved later using get_tab_metadata.
func set_tab_text_direction(direction: int enumControl.TextDirection) -> void#
Sets tab title base writing direction.
func set_tab_title(title: String) -> void#
Sets a title for the tab at index tab_idx.
func set_tab_tooltip(tooltip: String) -> void#
Sets a tooltip 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.
Annotations #
Constants #
const ALIGNMENT_LEFT = 0 enum AlignmentMode#
Places tabs to the left.
const ALIGNMENT_CENTER = 1 enum AlignmentMode#
Places tabs in the middle.
const ALIGNMENT_RIGHT = 2 enum AlignmentMode#
Places tabs to the right.
const ALIGNMENT_MAX = 3 enum AlignmentMode#
Represents the size of the AlignmentMode enum.
const CLOSE_BUTTON_SHOW_NEVER = 0 enum CloseButtonDisplayPolicy#
Never show the close buttons.
const CLOSE_BUTTON_SHOW_ACTIVE_ONLY = 1 enum CloseButtonDisplayPolicy#
Only show the close button on the currently active tab.
const CLOSE_BUTTON_SHOW_ALWAYS = 2 enum CloseButtonDisplayPolicy#
Show the close button on all tabs.
const CLOSE_BUTTON_MAX = 3 enum CloseButtonDisplayPolicy#
Represents the size of the CloseButtonDisplayPolicy enum.
Constructors #
Enums #
AlignmentMode#
enum AlignmentMode {
ALIGNMENT_LEFT = 0,
ALIGNMENT_CENTER = 1,
ALIGNMENT_RIGHT = 2,
ALIGNMENT_MAX = 3,
}CloseButtonDisplayPolicy#
enum CloseButtonDisplayPolicy {
CLOSE_BUTTON_SHOW_NEVER = 0,
CLOSE_BUTTON_SHOW_ACTIVE_ONLY = 1,
CLOSE_BUTTON_SHOW_ALWAYS = 2,
CLOSE_BUTTON_MAX = 3,
} Operators #
Signals #
signal active_tab_rearranged(idx_to: int)#
Emitted when the active tab is rearranged via mouse drag. See drag_to_rearrange_enabled.
signal tab_button_pressed(tab: int)#
Emitted when a tab's right button is pressed. See set_tab_button_icon.
signal tab_changed(tab: int)#
Emitted when switching to another tab.
signal tab_clicked(tab: int)#
Emitted when a tab is clicked, even if it is the current tab.
signal tab_close_pressed(tab: int)#
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:
GDScript
$TabBar.tab_close_pressed.connect($TabBar.remove_tab)C#
GetNode("TabBar").TabClosePressed += GetNode("TabBar").RemoveTab;signal tab_hovered(tab: int)#
Emitted when a tab is hovered by the mouse.
signal tab_rmb_clicked(tab: int)#
Emitted when a tab is right-clicked. select_with_rmb must be enabled.
signal tab_selected(tab: int)#
Emitted when a tab is selected via click, directional input, or script, even if it is the current tab.
Theme Items #
self["theme_override_colors/drop_mark_color"] = Color(1, 1, 1, 1) as Color#
Modulation color for the drop_mark icon.
self["theme_override_colors/font_disabled_color"] = Color(0.875, 0.875, 0.875, 0.5) as Color#
Font color of disabled tabs.
self["theme_override_colors/font_hovered_color"] = Color(0.95, 0.95, 0.95, 1) as Color#
Font color of the currently hovered tab. Does not apply to the selected tab.
self["theme_override_colors/font_outline_color"] = Color(0, 0, 0, 1) as Color#
The tint of text outline of the tab name.
self["theme_override_colors/font_selected_color"] = Color(0.95, 0.95, 0.95, 1) as Color#
Font color of the currently selected tab.
self["theme_override_colors/font_unselected_color"] = Color(0.7, 0.7, 0.7, 1) as Color#
Font color of the other, unselected tabs.
self["theme_override_constants/h_separation"] = 4 as int#
The horizontal separation between the elements inside tabs.
self["theme_override_constants/icon_max_width"] = 0 as int#
The maximum allowed width of the tab's icon. This limit is applied on top of the default size of the icon, but before the value set with set_tab_icon_max_width. The height is adjusted according to the icon's ratio.
self["theme_override_constants/outline_size"] = 0 as int#
The size of the tab text outline.
Note: If using a font with FontFile.multichannel_signed_distance_field enabled, its FontFile.msdf_pixel_range must be set to at least twice the value of outline_size for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.
self["theme_override_fonts/font"] = font as Font#
The font used to draw tab names.
self["theme_override_font_sizes/font_size"] = font_size as int#
Font size of the tab names.
self["theme_override_icons/close"] = icon as Texture2D#
The icon for the close button (see tab_close_display_policy).
self["theme_override_icons/decrement"] = icon as Texture2D#
Icon for the left arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the first tab is visible), it appears semi-transparent.
self["theme_override_icons/decrement_highlight"] = icon as Texture2D#
Icon for the left arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor.
self["theme_override_icons/drop_mark"] = icon as Texture2D#
Icon shown to indicate where a dragged tab is gonna be dropped (see drag_to_rearrange_enabled).
self["theme_override_icons/increment"] = icon as Texture2D#
Icon for the right arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the last tab is visible) it appears semi-transparent.
self["theme_override_icons/increment_highlight"] = icon as Texture2D#
Icon for the right arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor.
self["theme_override_styles/button_highlight"] = style as StyleBox#
Background of the tab and close buttons when they're being hovered with the cursor.
self["theme_override_styles/button_pressed"] = style as StyleBox#
Background of the tab and close buttons when it's being pressed.
self["theme_override_styles/tab_disabled"] = style as StyleBox#
The style of disabled tabs.
self["theme_override_styles/tab_focus"] = style as StyleBox#
StyleBox used when the TabBar is focused. The tab_focus StyleBox is displayed over the base StyleBox of the selected tab, so a partially transparent StyleBox should be used to ensure the base StyleBox remains visible. A StyleBox that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a StyleBoxEmpty resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
self["theme_override_styles/tab_hovered"] = style as StyleBox#
The style of the currently hovered tab. Does not apply to the selected tab.
Note: This style will be drawn with the same width as tab_unselected at minimum.
self["theme_override_styles/tab_selected"] = style as StyleBox#
The style of the currently selected tab.
self["theme_override_styles/tab_unselected"] = style as StyleBox#
The style of the other, unselected tabs.