class_tabcontainer.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the TabContainer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_TabContainer:
  6. TabContainer
  7. ============
  8. **Inherits:** :ref:`Container<class_Container>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Tabbed Container.
  13. Properties
  14. ----------
  15. +---------------------------------------------+-----------------------------------------------------------------------------------------+
  16. | :ref:`int<class_int>` | :ref:`current_tab<class_TabContainer_property_current_tab>` |
  17. +---------------------------------------------+-----------------------------------------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`drag_to_rearrange_enabled<class_TabContainer_property_drag_to_rearrange_enabled>` |
  19. +---------------------------------------------+-----------------------------------------------------------------------------------------+
  20. | :ref:`TabAlign<enum_TabContainer_TabAlign>` | :ref:`tab_align<class_TabContainer_property_tab_align>` |
  21. +---------------------------------------------+-----------------------------------------------------------------------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`tabs_visible<class_TabContainer_property_tabs_visible>` |
  23. +---------------------------------------------+-----------------------------------------------------------------------------------------+
  24. Methods
  25. -------
  26. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Control<class_Control>` | :ref:`get_current_tab_control<class_TabContainer_method_get_current_tab_control>` **(** **)** const |
  28. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Popup<class_Popup>` | :ref:`get_popup<class_TabContainer_method_get_popup>` **(** **)** const |
  30. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`get_previous_tab<class_TabContainer_method_get_previous_tab>` **(** **)** const |
  32. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Control<class_Control>` | :ref:`get_tab_control<class_TabContainer_method_get_tab_control>` **(** :ref:`int<class_int>` idx **)** const |
  34. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`int<class_int>` | :ref:`get_tab_count<class_TabContainer_method_get_tab_count>` **(** **)** const |
  36. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`get_tab_disabled<class_TabContainer_method_get_tab_disabled>` **(** :ref:`int<class_int>` tab_idx **)** const |
  38. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Texture<class_Texture>` | :ref:`get_tab_icon<class_TabContainer_method_get_tab_icon>` **(** :ref:`int<class_int>` tab_idx **)** const |
  40. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`String<class_String>` | :ref:`get_tab_title<class_TabContainer_method_get_tab_title>` **(** :ref:`int<class_int>` tab_idx **)** const |
  42. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`get_tabs_rearrange_group<class_TabContainer_method_get_tabs_rearrange_group>` **(** **)** const |
  44. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_popup<class_TabContainer_method_set_popup>` **(** :ref:`Node<class_Node>` popup **)** |
  46. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`set_tab_disabled<class_TabContainer_method_set_tab_disabled>` **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)** |
  48. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_tab_icon<class_TabContainer_method_set_tab_icon>` **(** :ref:`int<class_int>` tab_idx, :ref:`Texture<class_Texture>` icon **)** |
  50. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`set_tab_title<class_TabContainer_method_set_tab_title>` **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` title **)** |
  52. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_tabs_rearrange_group<class_TabContainer_method_set_tabs_rearrange_group>` **(** :ref:`int<class_int>` group_id **)** |
  54. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  55. Theme Properties
  56. ----------------
  57. +---------------------------------+---------------------+
  58. | :ref:`Texture<class_Texture>` | decrement |
  59. +---------------------------------+---------------------+
  60. | :ref:`Texture<class_Texture>` | decrement_highlight |
  61. +---------------------------------+---------------------+
  62. | :ref:`Font<class_Font>` | font |
  63. +---------------------------------+---------------------+
  64. | :ref:`Color<class_Color>` | font_color_bg |
  65. +---------------------------------+---------------------+
  66. | :ref:`Color<class_Color>` | font_color_disabled |
  67. +---------------------------------+---------------------+
  68. | :ref:`Color<class_Color>` | font_color_fg |
  69. +---------------------------------+---------------------+
  70. | :ref:`int<class_int>` | hseparation |
  71. +---------------------------------+---------------------+
  72. | :ref:`Texture<class_Texture>` | increment |
  73. +---------------------------------+---------------------+
  74. | :ref:`Texture<class_Texture>` | increment_highlight |
  75. +---------------------------------+---------------------+
  76. | :ref:`int<class_int>` | label_valign_bg |
  77. +---------------------------------+---------------------+
  78. | :ref:`int<class_int>` | label_valign_fg |
  79. +---------------------------------+---------------------+
  80. | :ref:`Texture<class_Texture>` | menu |
  81. +---------------------------------+---------------------+
  82. | :ref:`Texture<class_Texture>` | menu_highlight |
  83. +---------------------------------+---------------------+
  84. | :ref:`StyleBox<class_StyleBox>` | panel |
  85. +---------------------------------+---------------------+
  86. | :ref:`int<class_int>` | side_margin |
  87. +---------------------------------+---------------------+
  88. | :ref:`StyleBox<class_StyleBox>` | tab_bg |
  89. +---------------------------------+---------------------+
  90. | :ref:`StyleBox<class_StyleBox>` | tab_disabled |
  91. +---------------------------------+---------------------+
  92. | :ref:`StyleBox<class_StyleBox>` | tab_fg |
  93. +---------------------------------+---------------------+
  94. | :ref:`int<class_int>` | top_margin |
  95. +---------------------------------+---------------------+
  96. Signals
  97. -------
  98. .. _class_TabContainer_signal_pre_popup_pressed:
  99. - **pre_popup_pressed** **(** **)**
  100. Emitted when the ``TabContainer``'s :ref:`Popup<class_Popup>` button is clicked. See :ref:`set_popup<class_TabContainer_method_set_popup>` for details.
  101. ----
  102. .. _class_TabContainer_signal_tab_changed:
  103. - **tab_changed** **(** :ref:`int<class_int>` tab **)**
  104. Emitted when switching to another tab.
  105. ----
  106. .. _class_TabContainer_signal_tab_selected:
  107. - **tab_selected** **(** :ref:`int<class_int>` tab **)**
  108. Emitted when a tab is selected, even if it is the current tab.
  109. Enumerations
  110. ------------
  111. .. _enum_TabContainer_TabAlign:
  112. .. _class_TabContainer_constant_ALIGN_LEFT:
  113. .. _class_TabContainer_constant_ALIGN_CENTER:
  114. .. _class_TabContainer_constant_ALIGN_RIGHT:
  115. enum **TabAlign**:
  116. - **ALIGN_LEFT** = **0** --- Align the tabs to the left.
  117. - **ALIGN_CENTER** = **1** --- Align the tabs to the center.
  118. - **ALIGN_RIGHT** = **2** --- Align the tabs to the right.
  119. Description
  120. -----------
  121. Sets the active tab's ``visible`` property to the value ``true``. Sets all other children's to ``false``.
  122. Ignores non-:ref:`Control<class_Control>` children.
  123. Individual tabs are always visible unless you use :ref:`set_tab_disabled<class_TabContainer_method_set_tab_disabled>` and :ref:`set_tab_title<class_TabContainer_method_set_tab_title>` to hide it.
  124. To hide only a tab's content, nest the content inside a child :ref:`Control<class_Control>`, so it receives the ``TabContainer``'s visibility setting instead.
  125. Property Descriptions
  126. ---------------------
  127. .. _class_TabContainer_property_current_tab:
  128. - :ref:`int<class_int>` **current_tab**
  129. +----------+------------------------+
  130. | *Setter* | set_current_tab(value) |
  131. +----------+------------------------+
  132. | *Getter* | get_current_tab() |
  133. +----------+------------------------+
  134. The current tab index. When set, this index's :ref:`Control<class_Control>` node's ``visible`` property is set to ``true`` and all others are set to ``false``.
  135. ----
  136. .. _class_TabContainer_property_drag_to_rearrange_enabled:
  137. - :ref:`bool<class_bool>` **drag_to_rearrange_enabled**
  138. +----------+--------------------------------------+
  139. | *Setter* | set_drag_to_rearrange_enabled(value) |
  140. +----------+--------------------------------------+
  141. | *Getter* | get_drag_to_rearrange_enabled() |
  142. +----------+--------------------------------------+
  143. If ``true``, tabs can be rearranged with mouse drag.
  144. ----
  145. .. _class_TabContainer_property_tab_align:
  146. - :ref:`TabAlign<enum_TabContainer_TabAlign>` **tab_align**
  147. +----------+----------------------+
  148. | *Setter* | set_tab_align(value) |
  149. +----------+----------------------+
  150. | *Getter* | get_tab_align() |
  151. +----------+----------------------+
  152. The alignment of all tabs in the tab container. See the ``ALIGN_*`` constants for details.
  153. ----
  154. .. _class_TabContainer_property_tabs_visible:
  155. - :ref:`bool<class_bool>` **tabs_visible**
  156. +----------+-------------------------+
  157. | *Setter* | set_tabs_visible(value) |
  158. +----------+-------------------------+
  159. | *Getter* | are_tabs_visible() |
  160. +----------+-------------------------+
  161. If ``true``, tabs are visible. If ``false``, tabs' content and titles are hidden. Default value: ``true``.
  162. Method Descriptions
  163. -------------------
  164. .. _class_TabContainer_method_get_current_tab_control:
  165. - :ref:`Control<class_Control>` **get_current_tab_control** **(** **)** const
  166. Returns the child :ref:`Control<class_Control>` node located at the active tab index.
  167. ----
  168. .. _class_TabContainer_method_get_popup:
  169. - :ref:`Popup<class_Popup>` **get_popup** **(** **)** const
  170. Returns the :ref:`Popup<class_Popup>` node instance if one has been set already with :ref:`set_popup<class_TabContainer_method_set_popup>`.
  171. ----
  172. .. _class_TabContainer_method_get_previous_tab:
  173. - :ref:`int<class_int>` **get_previous_tab** **(** **)** const
  174. Returns the previously active tab index.
  175. ----
  176. .. _class_TabContainer_method_get_tab_control:
  177. - :ref:`Control<class_Control>` **get_tab_control** **(** :ref:`int<class_int>` idx **)** const
  178. Returns the currently visible tab's :ref:`Control<class_Control>` node.
  179. ----
  180. .. _class_TabContainer_method_get_tab_count:
  181. - :ref:`int<class_int>` **get_tab_count** **(** **)** const
  182. Returns the number of tabs.
  183. ----
  184. .. _class_TabContainer_method_get_tab_disabled:
  185. - :ref:`bool<class_bool>` **get_tab_disabled** **(** :ref:`int<class_int>` tab_idx **)** const
  186. Returns ``true`` if the tab at index ``tab_idx`` is disabled.
  187. ----
  188. .. _class_TabContainer_method_get_tab_icon:
  189. - :ref:`Texture<class_Texture>` **get_tab_icon** **(** :ref:`int<class_int>` tab_idx **)** const
  190. Returns the :ref:`Texture<class_Texture>` for the tab at index ``tab_idx`` or null if the tab has no :ref:`Texture<class_Texture>`.
  191. ----
  192. .. _class_TabContainer_method_get_tab_title:
  193. - :ref:`String<class_String>` **get_tab_title** **(** :ref:`int<class_int>` tab_idx **)** const
  194. Returns the title of the tab at index ``tab_idx``. Tab titles default to the name of the indexed child node, but this can be overridden with :ref:`set_tab_title<class_TabContainer_method_set_tab_title>`.
  195. ----
  196. .. _class_TabContainer_method_get_tabs_rearrange_group:
  197. - :ref:`int<class_int>` **get_tabs_rearrange_group** **(** **)** const
  198. Returns the ``TabContainer`` rearrange group id.
  199. ----
  200. .. _class_TabContainer_method_set_popup:
  201. - void **set_popup** **(** :ref:`Node<class_Node>` popup **)**
  202. If set on a :ref:`Popup<class_Popup>` node instance, a popup menu icon appears in the top-right corner of the ``TabContainer``. Clicking it will expand the :ref:`Popup<class_Popup>` node.
  203. ----
  204. .. _class_TabContainer_method_set_tab_disabled:
  205. - void **set_tab_disabled** **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)**
  206. If ``disabled`` is ``false``, hides the tab at index ``tab_idx``. Note that its title text will remain, unless also removed with :ref:`set_tab_title<class_TabContainer_method_set_tab_title>`.
  207. ----
  208. .. _class_TabContainer_method_set_tab_icon:
  209. - void **set_tab_icon** **(** :ref:`int<class_int>` tab_idx, :ref:`Texture<class_Texture>` icon **)**
  210. Sets an icon for the tab at index ``tab_idx``.
  211. ----
  212. .. _class_TabContainer_method_set_tab_title:
  213. - void **set_tab_title** **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` title **)**
  214. Sets a title for the tab at index ``tab_idx``. Tab titles default to the name of the indexed child node, but this can be overridden with :ref:`set_tab_title<class_TabContainer_method_set_tab_title>`.
  215. ----
  216. .. _class_TabContainer_method_set_tabs_rearrange_group:
  217. - void **set_tabs_rearrange_group** **(** :ref:`int<class_int>` group_id **)**
  218. Defines rearrange group id, choose for each ``TabContainer`` the same value to enable tab drag between ``TabContainer``. Enable drag with ``set_drag_to_rearrange_enabled(true)``.