class_tree.rst 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Tree.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Tree:
  6. Tree
  7. ====
  8. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Control to show a tree of items.
  10. Description
  11. -----------
  12. This shows a tree of items that can be selected, expanded and collapsed. The tree can have multiple columns with custom controls like text editing, buttons and popups. It can be useful for structured displays and interactions.
  13. Trees are built via code, using :ref:`TreeItem<class_TreeItem>` objects to create the structure. They have a single root but multiple roots can be simulated if a dummy hidden root is added.
  14. .. tabs::
  15. .. code-tab:: gdscript
  16. func _ready():
  17. var tree = Tree.new()
  18. var root = tree.create_item()
  19. tree.hide_root = true
  20. var child1 = tree.create_item(root)
  21. var child2 = tree.create_item(root)
  22. var subchild1 = tree.create_item(child1)
  23. subchild1.set_text(0, "Subchild1")
  24. .. code-tab:: csharp
  25. public override void _Ready()
  26. {
  27. var tree = new Tree();
  28. TreeItem root = tree.CreateItem();
  29. tree.HideRoot = true;
  30. TreeItem child1 = tree.CreateItem(root);
  31. TreeItem child2 = tree.CreateItem(root);
  32. TreeItem subchild1 = tree.CreateItem(child1);
  33. subchild1.SetText(0, "Subchild1");
  34. }
  35. To iterate over all the :ref:`TreeItem<class_TreeItem>` objects in a ``Tree`` object, use :ref:`TreeItem.get_next<class_TreeItem_method_get_next>` and :ref:`TreeItem.get_first_child<class_TreeItem_method_get_first_child>` after getting the root through :ref:`get_root<class_Tree_method_get_root>`. You can use :ref:`Object.free<class_Object_method_free>` on a :ref:`TreeItem<class_TreeItem>` to remove it from the ``Tree``.
  36. Properties
  37. ----------
  38. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  39. | :ref:`bool<class_bool>` | :ref:`allow_reselect<class_Tree_property_allow_reselect>` | ``false`` |
  40. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`allow_rmb_select<class_Tree_property_allow_rmb_select>` | ``false`` |
  42. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | clip_contents | ``true`` (overrides :ref:`Control<class_Control_property_clip_contents>`) |
  44. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`column_titles_visible<class_Tree_property_column_titles_visible>` | ``false`` |
  46. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`columns<class_Tree_property_columns>` | ``1`` |
  48. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  49. | :ref:`int<class_int>` | :ref:`drop_mode_flags<class_Tree_property_drop_mode_flags>` | ``0`` |
  50. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  51. | :ref:`FocusMode<enum_Control_FocusMode>` | focus_mode | ``2`` (overrides :ref:`Control<class_Control_property_focus_mode>`) |
  52. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  53. | :ref:`bool<class_bool>` | :ref:`hide_folding<class_Tree_property_hide_folding>` | ``false`` |
  54. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  55. | :ref:`bool<class_bool>` | :ref:`hide_root<class_Tree_property_hide_root>` | ``false`` |
  56. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  57. | :ref:`bool<class_bool>` | :ref:`scroll_horizontal_enabled<class_Tree_property_scroll_horizontal_enabled>` | ``true`` |
  58. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  59. | :ref:`bool<class_bool>` | :ref:`scroll_vertical_enabled<class_Tree_property_scroll_vertical_enabled>` | ``true`` |
  60. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  61. | :ref:`SelectMode<enum_Tree_SelectMode>` | :ref:`select_mode<class_Tree_property_select_mode>` | ``0`` |
  62. +------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
  63. Methods
  64. -------
  65. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`clear<class_Tree_method_clear>` **(** **)** |
  67. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`clear_column_title_opentype_features<class_Tree_method_clear_column_title_opentype_features>` **(** :ref:`int<class_int>` column **)** |
  69. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`TreeItem<class_TreeItem>` | :ref:`create_item<class_Tree_method_create_item>` **(** :ref:`TreeItem<class_TreeItem>` parent=null, :ref:`int<class_int>` idx=-1 **)** |
  71. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`bool<class_bool>` | :ref:`edit_selected<class_Tree_method_edit_selected>` **(** **)** |
  73. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`ensure_cursor_is_visible<class_Tree_method_ensure_cursor_is_visible>` **(** **)** |
  75. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`int<class_int>` | :ref:`get_button_id_at_position<class_Tree_method_get_button_id_at_position>` **(** :ref:`Vector2<class_Vector2>` position **)** |const| |
  77. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`int<class_int>` | :ref:`get_column_at_position<class_Tree_method_get_column_at_position>` **(** :ref:`Vector2<class_Vector2>` position **)** |const| |
  79. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`int<class_int>` | :ref:`get_column_expand_ratio<class_Tree_method_get_column_expand_ratio>` **(** :ref:`int<class_int>` column **)** |const| |
  81. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`String<class_String>` | :ref:`get_column_title<class_Tree_method_get_column_title>` **(** :ref:`int<class_int>` column **)** |const| |
  83. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`TextDirection<enum_Control_TextDirection>` | :ref:`get_column_title_direction<class_Tree_method_get_column_title_direction>` **(** :ref:`int<class_int>` column **)** |const| |
  85. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`String<class_String>` | :ref:`get_column_title_language<class_Tree_method_get_column_title_language>` **(** :ref:`int<class_int>` column **)** |const| |
  87. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`int<class_int>` | :ref:`get_column_title_opentype_feature<class_Tree_method_get_column_title_opentype_feature>` **(** :ref:`int<class_int>` column, :ref:`String<class_String>` tag **)** |const| |
  89. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`int<class_int>` | :ref:`get_column_width<class_Tree_method_get_column_width>` **(** :ref:`int<class_int>` column **)** |const| |
  91. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`Rect2<class_Rect2>` | :ref:`get_custom_popup_rect<class_Tree_method_get_custom_popup_rect>` **(** **)** |const| |
  93. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`int<class_int>` | :ref:`get_drop_section_at_position<class_Tree_method_get_drop_section_at_position>` **(** :ref:`Vector2<class_Vector2>` position **)** |const| |
  95. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`TreeItem<class_TreeItem>` | :ref:`get_edited<class_Tree_method_get_edited>` **(** **)** |const| |
  97. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`int<class_int>` | :ref:`get_edited_column<class_Tree_method_get_edited_column>` **(** **)** |const| |
  99. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`Rect2<class_Rect2>` | :ref:`get_item_area_rect<class_Tree_method_get_item_area_rect>` **(** :ref:`TreeItem<class_TreeItem>` item, :ref:`int<class_int>` column=-1 **)** |const| |
  101. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`TreeItem<class_TreeItem>` | :ref:`get_item_at_position<class_Tree_method_get_item_at_position>` **(** :ref:`Vector2<class_Vector2>` position **)** |const| |
  103. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`TreeItem<class_TreeItem>` | :ref:`get_next_selected<class_Tree_method_get_next_selected>` **(** :ref:`TreeItem<class_TreeItem>` from **)** |
  105. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`int<class_int>` | :ref:`get_pressed_button<class_Tree_method_get_pressed_button>` **(** **)** |const| |
  107. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`TreeItem<class_TreeItem>` | :ref:`get_root<class_Tree_method_get_root>` **(** **)** |const| |
  109. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`Vector2<class_Vector2>` | :ref:`get_scroll<class_Tree_method_get_scroll>` **(** **)** |const| |
  111. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`TreeItem<class_TreeItem>` | :ref:`get_selected<class_Tree_method_get_selected>` **(** **)** |const| |
  113. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`int<class_int>` | :ref:`get_selected_column<class_Tree_method_get_selected_column>` **(** **)** |const| |
  115. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`bool<class_bool>` | :ref:`is_column_clipping_content<class_Tree_method_is_column_clipping_content>` **(** :ref:`int<class_int>` column **)** |const| |
  117. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`bool<class_bool>` | :ref:`is_column_expanding<class_Tree_method_is_column_expanding>` **(** :ref:`int<class_int>` column **)** |const| |
  119. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | void | :ref:`scroll_to_item<class_Tree_method_scroll_to_item>` **(** :ref:`TreeItem<class_TreeItem>` item, :ref:`bool<class_bool>` center_on_item=false **)** |
  121. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | void | :ref:`set_column_clip_content<class_Tree_method_set_column_clip_content>` **(** :ref:`int<class_int>` column, :ref:`bool<class_bool>` enable **)** |
  123. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | void | :ref:`set_column_custom_minimum_width<class_Tree_method_set_column_custom_minimum_width>` **(** :ref:`int<class_int>` column, :ref:`int<class_int>` min_width **)** |
  125. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | void | :ref:`set_column_expand<class_Tree_method_set_column_expand>` **(** :ref:`int<class_int>` column, :ref:`bool<class_bool>` expand **)** |
  127. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | void | :ref:`set_column_expand_ratio<class_Tree_method_set_column_expand_ratio>` **(** :ref:`int<class_int>` column, :ref:`int<class_int>` ratio **)** |
  129. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | void | :ref:`set_column_title<class_Tree_method_set_column_title>` **(** :ref:`int<class_int>` column, :ref:`String<class_String>` title **)** |
  131. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | void | :ref:`set_column_title_direction<class_Tree_method_set_column_title_direction>` **(** :ref:`int<class_int>` column, :ref:`TextDirection<enum_Control_TextDirection>` direction **)** |
  133. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | void | :ref:`set_column_title_language<class_Tree_method_set_column_title_language>` **(** :ref:`int<class_int>` column, :ref:`String<class_String>` language **)** |
  135. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | void | :ref:`set_column_title_opentype_feature<class_Tree_method_set_column_title_opentype_feature>` **(** :ref:`int<class_int>` column, :ref:`String<class_String>` tag, :ref:`int<class_int>` value **)** |
  137. +--------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. Theme Properties
  139. ----------------
  140. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  141. | :ref:`Color<class_Color>` | :ref:`children_hl_line_color<class_Tree_theme_color_children_hl_line_color>` | ``Color(0.27, 0.27, 0.27, 1)`` |
  142. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  143. | :ref:`Color<class_Color>` | :ref:`custom_button_font_highlight<class_Tree_theme_color_custom_button_font_highlight>` | ``Color(0.95, 0.95, 0.95, 1)`` |
  144. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  145. | :ref:`Color<class_Color>` | :ref:`drop_position_color<class_Tree_theme_color_drop_position_color>` | ``Color(1, 0.3, 0.2, 1)`` |
  146. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  147. | :ref:`Color<class_Color>` | :ref:`font_color<class_Tree_theme_color_font_color>` | ``Color(0.7, 0.7, 0.7, 1)`` |
  148. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  149. | :ref:`Color<class_Color>` | :ref:`font_outline_color<class_Tree_theme_color_font_outline_color>` | ``Color(1, 1, 1, 1)`` |
  150. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  151. | :ref:`Color<class_Color>` | :ref:`font_selected_color<class_Tree_theme_color_font_selected_color>` | ``Color(1, 1, 1, 1)`` |
  152. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  153. | :ref:`Color<class_Color>` | :ref:`guide_color<class_Tree_theme_color_guide_color>` | ``Color(0.7, 0.7, 0.7, 0.25)`` |
  154. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  155. | :ref:`Color<class_Color>` | :ref:`parent_hl_line_color<class_Tree_theme_color_parent_hl_line_color>` | ``Color(0.27, 0.27, 0.27, 1)`` |
  156. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  157. | :ref:`Color<class_Color>` | :ref:`relationship_line_color<class_Tree_theme_color_relationship_line_color>` | ``Color(0.27, 0.27, 0.27, 1)`` |
  158. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  159. | :ref:`Color<class_Color>` | :ref:`title_button_color<class_Tree_theme_color_title_button_color>` | ``Color(0.875, 0.875, 0.875, 1)`` |
  160. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  161. | :ref:`int<class_int>` | :ref:`button_margin<class_Tree_theme_constant_button_margin>` | ``4`` |
  162. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  163. | :ref:`int<class_int>` | :ref:`children_hl_line_width<class_Tree_theme_constant_children_hl_line_width>` | ``1`` |
  164. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  165. | :ref:`int<class_int>` | :ref:`draw_guides<class_Tree_theme_constant_draw_guides>` | ``1`` |
  166. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  167. | :ref:`int<class_int>` | :ref:`draw_relationship_lines<class_Tree_theme_constant_draw_relationship_lines>` | ``0`` |
  168. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  169. | :ref:`int<class_int>` | :ref:`hseparation<class_Tree_theme_constant_hseparation>` | ``4`` |
  170. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  171. | :ref:`int<class_int>` | :ref:`item_margin<class_Tree_theme_constant_item_margin>` | ``16`` |
  172. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  173. | :ref:`int<class_int>` | :ref:`outline_size<class_Tree_theme_constant_outline_size>` | ``0`` |
  174. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  175. | :ref:`int<class_int>` | :ref:`parent_hl_line_margin<class_Tree_theme_constant_parent_hl_line_margin>` | ``0`` |
  176. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  177. | :ref:`int<class_int>` | :ref:`parent_hl_line_width<class_Tree_theme_constant_parent_hl_line_width>` | ``1`` |
  178. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  179. | :ref:`int<class_int>` | :ref:`relationship_line_width<class_Tree_theme_constant_relationship_line_width>` | ``1`` |
  180. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  181. | :ref:`int<class_int>` | :ref:`scroll_border<class_Tree_theme_constant_scroll_border>` | ``4`` |
  182. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  183. | :ref:`int<class_int>` | :ref:`scroll_speed<class_Tree_theme_constant_scroll_speed>` | ``12`` |
  184. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  185. | :ref:`int<class_int>` | :ref:`vseparation<class_Tree_theme_constant_vseparation>` | ``4`` |
  186. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  187. | :ref:`Font<class_Font>` | :ref:`font<class_Tree_theme_font_font>` | |
  188. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  189. | :ref:`Font<class_Font>` | :ref:`title_button_font<class_Tree_theme_font_title_button_font>` | |
  190. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  191. | :ref:`int<class_int>` | :ref:`font_size<class_Tree_theme_font_size_font_size>` | |
  192. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  193. | :ref:`Texture2D<class_Texture2D>` | :ref:`arrow<class_Tree_theme_icon_arrow>` | |
  194. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  195. | :ref:`Texture2D<class_Texture2D>` | :ref:`arrow_collapsed<class_Tree_theme_icon_arrow_collapsed>` | |
  196. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  197. | :ref:`Texture2D<class_Texture2D>` | :ref:`arrow_collapsed_mirrored<class_Tree_theme_icon_arrow_collapsed_mirrored>` | |
  198. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  199. | :ref:`Texture2D<class_Texture2D>` | :ref:`checked<class_Tree_theme_icon_checked>` | |
  200. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  201. | :ref:`Texture2D<class_Texture2D>` | :ref:`indeterminate<class_Tree_theme_icon_indeterminate>` | |
  202. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  203. | :ref:`Texture2D<class_Texture2D>` | :ref:`select_arrow<class_Tree_theme_icon_select_arrow>` | |
  204. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  205. | :ref:`Texture2D<class_Texture2D>` | :ref:`unchecked<class_Tree_theme_icon_unchecked>` | |
  206. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  207. | :ref:`Texture2D<class_Texture2D>` | :ref:`updown<class_Tree_theme_icon_updown>` | |
  208. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  209. | :ref:`StyleBox<class_StyleBox>` | :ref:`bg<class_Tree_theme_style_bg>` | |
  210. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  211. | :ref:`StyleBox<class_StyleBox>` | :ref:`bg_focus<class_Tree_theme_style_bg_focus>` | |
  212. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  213. | :ref:`StyleBox<class_StyleBox>` | :ref:`button_pressed<class_Tree_theme_style_button_pressed>` | |
  214. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  215. | :ref:`StyleBox<class_StyleBox>` | :ref:`cursor<class_Tree_theme_style_cursor>` | |
  216. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  217. | :ref:`StyleBox<class_StyleBox>` | :ref:`cursor_unfocused<class_Tree_theme_style_cursor_unfocused>` | |
  218. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  219. | :ref:`StyleBox<class_StyleBox>` | :ref:`custom_button<class_Tree_theme_style_custom_button>` | |
  220. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  221. | :ref:`StyleBox<class_StyleBox>` | :ref:`custom_button_hover<class_Tree_theme_style_custom_button_hover>` | |
  222. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  223. | :ref:`StyleBox<class_StyleBox>` | :ref:`custom_button_pressed<class_Tree_theme_style_custom_button_pressed>` | |
  224. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  225. | :ref:`StyleBox<class_StyleBox>` | :ref:`selected<class_Tree_theme_style_selected>` | |
  226. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  227. | :ref:`StyleBox<class_StyleBox>` | :ref:`selected_focus<class_Tree_theme_style_selected_focus>` | |
  228. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  229. | :ref:`StyleBox<class_StyleBox>` | :ref:`title_button_hover<class_Tree_theme_style_title_button_hover>` | |
  230. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  231. | :ref:`StyleBox<class_StyleBox>` | :ref:`title_button_normal<class_Tree_theme_style_title_button_normal>` | |
  232. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  233. | :ref:`StyleBox<class_StyleBox>` | :ref:`title_button_pressed<class_Tree_theme_style_title_button_pressed>` | |
  234. +-----------------------------------+------------------------------------------------------------------------------------------+-----------------------------------+
  235. Signals
  236. -------
  237. .. _class_Tree_signal_button_pressed:
  238. - **button_pressed** **(** :ref:`TreeItem<class_TreeItem>` item, :ref:`int<class_int>` column, :ref:`int<class_int>` id **)**
  239. Emitted when a button on the tree was pressed (see :ref:`TreeItem.add_button<class_TreeItem_method_add_button>`).
  240. ----
  241. .. _class_Tree_signal_cell_selected:
  242. - **cell_selected** **(** **)**
  243. Emitted when a cell is selected.
  244. ----
  245. .. _class_Tree_signal_check_propagated_to_item:
  246. - **check_propagated_to_item** **(** :ref:`TreeItem<class_TreeItem>` item, :ref:`int<class_int>` column **)**
  247. Emitted when :ref:`TreeItem.propagate_check<class_TreeItem_method_propagate_check>` is called. Connect to this signal to process the items that are affected when :ref:`TreeItem.propagate_check<class_TreeItem_method_propagate_check>` is invoked. The order that the items affected will be processed is as follows: the item that invoked the method, children of that item, and finally parents of that item.
  248. ----
  249. .. _class_Tree_signal_column_title_pressed:
  250. - **column_title_pressed** **(** :ref:`int<class_int>` column **)**
  251. Emitted when a column's title is pressed.
  252. ----
  253. .. _class_Tree_signal_custom_popup_edited:
  254. - **custom_popup_edited** **(** :ref:`bool<class_bool>` arrow_clicked **)**
  255. Emitted when a cell with the :ref:`TreeItem.CELL_MODE_CUSTOM<class_TreeItem_constant_CELL_MODE_CUSTOM>` is clicked to be edited.
  256. ----
  257. .. _class_Tree_signal_empty_rmb:
  258. - **empty_rmb** **(** :ref:`Vector2<class_Vector2>` position **)**
  259. Emitted when the right mouse button is pressed in the empty space of the tree.
  260. ----
  261. .. _class_Tree_signal_empty_tree_rmb_selected:
  262. - **empty_tree_rmb_selected** **(** :ref:`Vector2<class_Vector2>` position **)**
  263. Emitted when the right mouse button is pressed if right mouse button selection is active and the tree is empty.
  264. ----
  265. .. _class_Tree_signal_item_activated:
  266. - **item_activated** **(** **)**
  267. Emitted when an item's label is double-clicked.
  268. ----
  269. .. _class_Tree_signal_item_collapsed:
  270. - **item_collapsed** **(** :ref:`TreeItem<class_TreeItem>` item **)**
  271. Emitted when an item is collapsed by a click on the folding arrow.
  272. ----
  273. .. _class_Tree_signal_item_custom_button_pressed:
  274. - **item_custom_button_pressed** **(** **)**
  275. Emitted when a custom button is pressed (i.e. in a :ref:`TreeItem.CELL_MODE_CUSTOM<class_TreeItem_constant_CELL_MODE_CUSTOM>` mode cell).
  276. ----
  277. .. _class_Tree_signal_item_double_clicked:
  278. - **item_double_clicked** **(** **)**
  279. Emitted when an item's icon is double-clicked.
  280. ----
  281. .. _class_Tree_signal_item_edited:
  282. - **item_edited** **(** **)**
  283. Emitted when an item is edited.
  284. ----
  285. .. _class_Tree_signal_item_rmb_edited:
  286. - **item_rmb_edited** **(** **)**
  287. Emitted when an item is edited using the right mouse button.
  288. ----
  289. .. _class_Tree_signal_item_rmb_selected:
  290. - **item_rmb_selected** **(** :ref:`Vector2<class_Vector2>` position **)**
  291. Emitted when an item is selected with the right mouse button.
  292. ----
  293. .. _class_Tree_signal_item_selected:
  294. - **item_selected** **(** **)**
  295. Emitted when an item is selected.
  296. ----
  297. .. _class_Tree_signal_multi_selected:
  298. - **multi_selected** **(** :ref:`TreeItem<class_TreeItem>` item, :ref:`int<class_int>` column, :ref:`bool<class_bool>` selected **)**
  299. Emitted instead of ``item_selected`` if ``select_mode`` is :ref:`SELECT_MULTI<class_Tree_constant_SELECT_MULTI>`.
  300. ----
  301. .. _class_Tree_signal_nothing_selected:
  302. - **nothing_selected** **(** **)**
  303. Emitted when a left mouse button click does not select any item.
  304. Enumerations
  305. ------------
  306. .. _enum_Tree_SelectMode:
  307. .. _class_Tree_constant_SELECT_SINGLE:
  308. .. _class_Tree_constant_SELECT_ROW:
  309. .. _class_Tree_constant_SELECT_MULTI:
  310. enum **SelectMode**:
  311. - **SELECT_SINGLE** = **0** --- Allows selection of a single cell at a time. From the perspective of items, only a single item is allowed to be selected. And there is only one column selected in the selected item.
  312. The focus cursor is always hidden in this mode, but it is positioned at the current selection, making the currently selected item the currently focused item.
  313. - **SELECT_ROW** = **1** --- Allows selection of a single row at a time. From the perspective of items, only a single items is allowed to be selected. And all the columns are selected in the selected item.
  314. The focus cursor is always hidden in this mode, but it is positioned at the first column of the current selection, making the currently selected item the currently focused item.
  315. - **SELECT_MULTI** = **2** --- Allows selection of multiple cells at the same time. From the perspective of items, multiple items are allowed to be selected. And there can be multiple columns selected in each selected item.
  316. The focus cursor is visible in this mode, the item or column under the cursor is not necessarily selected.
  317. ----
  318. .. _enum_Tree_DropModeFlags:
  319. .. _class_Tree_constant_DROP_MODE_DISABLED:
  320. .. _class_Tree_constant_DROP_MODE_ON_ITEM:
  321. .. _class_Tree_constant_DROP_MODE_INBETWEEN:
  322. enum **DropModeFlags**:
  323. - **DROP_MODE_DISABLED** = **0** --- Disables all drop sections, but still allows to detect the "on item" drop section by :ref:`get_drop_section_at_position<class_Tree_method_get_drop_section_at_position>`.
  324. \ **Note:** This is the default flag, it has no effect when combined with other flags.
  325. - **DROP_MODE_ON_ITEM** = **1** --- Enables the "on item" drop section. This drop section covers the entire item.
  326. When combined with :ref:`DROP_MODE_INBETWEEN<class_Tree_constant_DROP_MODE_INBETWEEN>`, this drop section halves the height and stays centered vertically.
  327. - **DROP_MODE_INBETWEEN** = **2** --- Enables "above item" and "below item" drop sections. The "above item" drop section covers the top half of the item, and the "below item" drop section covers the bottom half.
  328. When combined with :ref:`DROP_MODE_ON_ITEM<class_Tree_constant_DROP_MODE_ON_ITEM>`, these drop sections halves the height and stays on top / bottom accordingly.
  329. Property Descriptions
  330. ---------------------
  331. .. _class_Tree_property_allow_reselect:
  332. - :ref:`bool<class_bool>` **allow_reselect**
  333. +-----------+---------------------------+
  334. | *Default* | ``false`` |
  335. +-----------+---------------------------+
  336. | *Setter* | set_allow_reselect(value) |
  337. +-----------+---------------------------+
  338. | *Getter* | get_allow_reselect() |
  339. +-----------+---------------------------+
  340. If ``true``, the currently selected cell may be selected again.
  341. ----
  342. .. _class_Tree_property_allow_rmb_select:
  343. - :ref:`bool<class_bool>` **allow_rmb_select**
  344. +-----------+-----------------------------+
  345. | *Default* | ``false`` |
  346. +-----------+-----------------------------+
  347. | *Setter* | set_allow_rmb_select(value) |
  348. +-----------+-----------------------------+
  349. | *Getter* | get_allow_rmb_select() |
  350. +-----------+-----------------------------+
  351. If ``true``, a right mouse button click can select items.
  352. ----
  353. .. _class_Tree_property_column_titles_visible:
  354. - :ref:`bool<class_bool>` **column_titles_visible**
  355. +-----------+----------------------------------+
  356. | *Default* | ``false`` |
  357. +-----------+----------------------------------+
  358. | *Setter* | set_column_titles_visible(value) |
  359. +-----------+----------------------------------+
  360. | *Getter* | are_column_titles_visible() |
  361. +-----------+----------------------------------+
  362. If ``true``, column titles are visible.
  363. ----
  364. .. _class_Tree_property_columns:
  365. - :ref:`int<class_int>` **columns**
  366. +-----------+--------------------+
  367. | *Default* | ``1`` |
  368. +-----------+--------------------+
  369. | *Setter* | set_columns(value) |
  370. +-----------+--------------------+
  371. | *Getter* | get_columns() |
  372. +-----------+--------------------+
  373. The number of columns.
  374. ----
  375. .. _class_Tree_property_drop_mode_flags:
  376. - :ref:`int<class_int>` **drop_mode_flags**
  377. +-----------+----------------------------+
  378. | *Default* | ``0`` |
  379. +-----------+----------------------------+
  380. | *Setter* | set_drop_mode_flags(value) |
  381. +-----------+----------------------------+
  382. | *Getter* | get_drop_mode_flags() |
  383. +-----------+----------------------------+
  384. The drop mode as an OR combination of flags. See :ref:`DropModeFlags<enum_Tree_DropModeFlags>` constants. Once dropping is done, reverts to :ref:`DROP_MODE_DISABLED<class_Tree_constant_DROP_MODE_DISABLED>`. Setting this during :ref:`Control._can_drop_data<class_Control_method__can_drop_data>` is recommended.
  385. This controls the drop sections, i.e. the decision and drawing of possible drop locations based on the mouse position.
  386. ----
  387. .. _class_Tree_property_hide_folding:
  388. - :ref:`bool<class_bool>` **hide_folding**
  389. +-----------+-------------------------+
  390. | *Default* | ``false`` |
  391. +-----------+-------------------------+
  392. | *Setter* | set_hide_folding(value) |
  393. +-----------+-------------------------+
  394. | *Getter* | is_folding_hidden() |
  395. +-----------+-------------------------+
  396. If ``true``, the folding arrow is hidden.
  397. ----
  398. .. _class_Tree_property_hide_root:
  399. - :ref:`bool<class_bool>` **hide_root**
  400. +-----------+----------------------+
  401. | *Default* | ``false`` |
  402. +-----------+----------------------+
  403. | *Setter* | set_hide_root(value) |
  404. +-----------+----------------------+
  405. | *Getter* | is_root_hidden() |
  406. +-----------+----------------------+
  407. If ``true``, the tree's root is hidden.
  408. ----
  409. .. _class_Tree_property_scroll_horizontal_enabled:
  410. - :ref:`bool<class_bool>` **scroll_horizontal_enabled**
  411. +-----------+-----------------------------+
  412. | *Default* | ``true`` |
  413. +-----------+-----------------------------+
  414. | *Setter* | set_h_scroll_enabled(value) |
  415. +-----------+-----------------------------+
  416. | *Getter* | is_h_scroll_enabled() |
  417. +-----------+-----------------------------+
  418. If ``true``, enables horizontal scrolling.
  419. ----
  420. .. _class_Tree_property_scroll_vertical_enabled:
  421. - :ref:`bool<class_bool>` **scroll_vertical_enabled**
  422. +-----------+-----------------------------+
  423. | *Default* | ``true`` |
  424. +-----------+-----------------------------+
  425. | *Setter* | set_v_scroll_enabled(value) |
  426. +-----------+-----------------------------+
  427. | *Getter* | is_v_scroll_enabled() |
  428. +-----------+-----------------------------+
  429. If ``true``, enables vertical scrolling.
  430. ----
  431. .. _class_Tree_property_select_mode:
  432. - :ref:`SelectMode<enum_Tree_SelectMode>` **select_mode**
  433. +-----------+------------------------+
  434. | *Default* | ``0`` |
  435. +-----------+------------------------+
  436. | *Setter* | set_select_mode(value) |
  437. +-----------+------------------------+
  438. | *Getter* | get_select_mode() |
  439. +-----------+------------------------+
  440. Allows single or multiple selection. See the :ref:`SelectMode<enum_Tree_SelectMode>` constants.
  441. Method Descriptions
  442. -------------------
  443. .. _class_Tree_method_clear:
  444. - void **clear** **(** **)**
  445. Clears the tree. This removes all items.
  446. ----
  447. .. _class_Tree_method_clear_column_title_opentype_features:
  448. - void **clear_column_title_opentype_features** **(** :ref:`int<class_int>` column **)**
  449. Removes all OpenType features from the item's text.
  450. ----
  451. .. _class_Tree_method_create_item:
  452. - :ref:`TreeItem<class_TreeItem>` **create_item** **(** :ref:`TreeItem<class_TreeItem>` parent=null, :ref:`int<class_int>` idx=-1 **)**
  453. Creates an item in the tree and adds it as a child of ``parent``, which can be either a valid :ref:`TreeItem<class_TreeItem>` or ``null``.
  454. If ``parent`` is ``null``, the root item will be the parent, or the new item will be the root itself if the tree is empty.
  455. The new item will be the ``idx``\ th child of parent, or it will be the last child if there are not enough siblings.
  456. ----
  457. .. _class_Tree_method_edit_selected:
  458. - :ref:`bool<class_bool>` **edit_selected** **(** **)**
  459. Edits the selected tree item as if it was clicked. The item must be set editable with :ref:`TreeItem.set_editable<class_TreeItem_method_set_editable>`. Returns ``true`` if the item could be edited. Fails if no item is selected.
  460. ----
  461. .. _class_Tree_method_ensure_cursor_is_visible:
  462. - void **ensure_cursor_is_visible** **(** **)**
  463. Makes the currently focused cell visible.
  464. This will scroll the tree if necessary. In :ref:`SELECT_ROW<class_Tree_constant_SELECT_ROW>` mode, this will not do horizontal scrolling, as all the cells in the selected row is focused logically.
  465. \ **Note:** Despite the name of this method, the focus cursor itself is only visible in :ref:`SELECT_MULTI<class_Tree_constant_SELECT_MULTI>` mode.
  466. ----
  467. .. _class_Tree_method_get_button_id_at_position:
  468. - :ref:`int<class_int>` **get_button_id_at_position** **(** :ref:`Vector2<class_Vector2>` position **)** |const|
  469. Returns the button id at ``position``, or -1 if no button is there.
  470. ----
  471. .. _class_Tree_method_get_column_at_position:
  472. - :ref:`int<class_int>` **get_column_at_position** **(** :ref:`Vector2<class_Vector2>` position **)** |const|
  473. Returns the column index at ``position``, or -1 if no item is there.
  474. ----
  475. .. _class_Tree_method_get_column_expand_ratio:
  476. - :ref:`int<class_int>` **get_column_expand_ratio** **(** :ref:`int<class_int>` column **)** |const|
  477. ----
  478. .. _class_Tree_method_get_column_title:
  479. - :ref:`String<class_String>` **get_column_title** **(** :ref:`int<class_int>` column **)** |const|
  480. Returns the column's title.
  481. ----
  482. .. _class_Tree_method_get_column_title_direction:
  483. - :ref:`TextDirection<enum_Control_TextDirection>` **get_column_title_direction** **(** :ref:`int<class_int>` column **)** |const|
  484. Returns column title base writing direction.
  485. ----
  486. .. _class_Tree_method_get_column_title_language:
  487. - :ref:`String<class_String>` **get_column_title_language** **(** :ref:`int<class_int>` column **)** |const|
  488. Returns column title language code.
  489. ----
  490. .. _class_Tree_method_get_column_title_opentype_feature:
  491. - :ref:`int<class_int>` **get_column_title_opentype_feature** **(** :ref:`int<class_int>` column, :ref:`String<class_String>` tag **)** |const|
  492. Returns OpenType feature ``tag`` of the column title.
  493. ----
  494. .. _class_Tree_method_get_column_width:
  495. - :ref:`int<class_int>` **get_column_width** **(** :ref:`int<class_int>` column **)** |const|
  496. Returns the column's width in pixels.
  497. ----
  498. .. _class_Tree_method_get_custom_popup_rect:
  499. - :ref:`Rect2<class_Rect2>` **get_custom_popup_rect** **(** **)** |const|
  500. Returns the rectangle for custom popups. Helper to create custom cell controls that display a popup. See :ref:`TreeItem.set_cell_mode<class_TreeItem_method_set_cell_mode>`.
  501. ----
  502. .. _class_Tree_method_get_drop_section_at_position:
  503. - :ref:`int<class_int>` **get_drop_section_at_position** **(** :ref:`Vector2<class_Vector2>` position **)** |const|
  504. Returns the drop section at ``position``, or -100 if no item is there.
  505. Values -1, 0, or 1 will be returned for the "above item", "on item", and "below item" drop sections, respectively. See :ref:`DropModeFlags<enum_Tree_DropModeFlags>` for a description of each drop section.
  506. To get the item which the returned drop section is relative to, use :ref:`get_item_at_position<class_Tree_method_get_item_at_position>`.
  507. ----
  508. .. _class_Tree_method_get_edited:
  509. - :ref:`TreeItem<class_TreeItem>` **get_edited** **(** **)** |const|
  510. Returns the currently edited item. Can be used with :ref:`item_edited<class_Tree_signal_item_edited>` to get the item that was modified.
  511. .. tabs::
  512. .. code-tab:: gdscript
  513. func _ready():
  514. $Tree.item_edited.connect(on_Tree_item_edited)
  515. func on_Tree_item_edited():
  516. print($Tree.get_edited()) # This item just got edited (e.g. checked).
  517. .. code-tab:: csharp
  518. public override void _Ready()
  519. {
  520. GetNode<Tree>("Tree").ItemEdited += OnTreeItemEdited;
  521. }
  522. public void OnTreeItemEdited()
  523. {
  524. GD.Print(GetNode<Tree>("Tree").GetEdited()); // This item just got edited (e.g. checked).
  525. }
  526. ----
  527. .. _class_Tree_method_get_edited_column:
  528. - :ref:`int<class_int>` **get_edited_column** **(** **)** |const|
  529. Returns the column for the currently edited item.
  530. ----
  531. .. _class_Tree_method_get_item_area_rect:
  532. - :ref:`Rect2<class_Rect2>` **get_item_area_rect** **(** :ref:`TreeItem<class_TreeItem>` item, :ref:`int<class_int>` column=-1 **)** |const|
  533. Returns the rectangle area for the specified :ref:`TreeItem<class_TreeItem>`. If ``column`` is specified, only get the position and size of that column, otherwise get the rectangle containing all columns.
  534. ----
  535. .. _class_Tree_method_get_item_at_position:
  536. - :ref:`TreeItem<class_TreeItem>` **get_item_at_position** **(** :ref:`Vector2<class_Vector2>` position **)** |const|
  537. Returns the tree item at the specified position (relative to the tree origin position).
  538. ----
  539. .. _class_Tree_method_get_next_selected:
  540. - :ref:`TreeItem<class_TreeItem>` **get_next_selected** **(** :ref:`TreeItem<class_TreeItem>` from **)**
  541. Returns the next selected :ref:`TreeItem<class_TreeItem>` after the given one, or ``null`` if the end is reached.
  542. If ``from`` is ``null``, this returns the first selected item.
  543. ----
  544. .. _class_Tree_method_get_pressed_button:
  545. - :ref:`int<class_int>` **get_pressed_button** **(** **)** |const|
  546. Returns the last pressed button's index.
  547. ----
  548. .. _class_Tree_method_get_root:
  549. - :ref:`TreeItem<class_TreeItem>` **get_root** **(** **)** |const|
  550. Returns the tree's root item, or ``null`` if the tree is empty.
  551. ----
  552. .. _class_Tree_method_get_scroll:
  553. - :ref:`Vector2<class_Vector2>` **get_scroll** **(** **)** |const|
  554. Returns the current scrolling position.
  555. ----
  556. .. _class_Tree_method_get_selected:
  557. - :ref:`TreeItem<class_TreeItem>` **get_selected** **(** **)** |const|
  558. Returns the currently focused item, or ``null`` if no item is focused.
  559. In :ref:`SELECT_ROW<class_Tree_constant_SELECT_ROW>` and :ref:`SELECT_SINGLE<class_Tree_constant_SELECT_SINGLE>` modes, the focused item is same as the selected item. In :ref:`SELECT_MULTI<class_Tree_constant_SELECT_MULTI>` mode, the focused item is the item under the focus cursor, not necessarily selected.
  560. To get the currently selected item(s), use :ref:`get_next_selected<class_Tree_method_get_next_selected>`.
  561. ----
  562. .. _class_Tree_method_get_selected_column:
  563. - :ref:`int<class_int>` **get_selected_column** **(** **)** |const|
  564. Returns the currently focused column, or -1 if no column is focused.
  565. In :ref:`SELECT_SINGLE<class_Tree_constant_SELECT_SINGLE>` mode, the focused column is the selected column. In :ref:`SELECT_ROW<class_Tree_constant_SELECT_ROW>` mode, the focused column is always 0 if any item is selected. In :ref:`SELECT_MULTI<class_Tree_constant_SELECT_MULTI>` mode, the focused column is the column under the focus cursor, and there are not necessarily any column selected.
  566. To tell whether a column of an item is selected, use :ref:`TreeItem.is_selected<class_TreeItem_method_is_selected>`.
  567. ----
  568. .. _class_Tree_method_is_column_clipping_content:
  569. - :ref:`bool<class_bool>` **is_column_clipping_content** **(** :ref:`int<class_int>` column **)** |const|
  570. ----
  571. .. _class_Tree_method_is_column_expanding:
  572. - :ref:`bool<class_bool>` **is_column_expanding** **(** :ref:`int<class_int>` column **)** |const|
  573. ----
  574. .. _class_Tree_method_scroll_to_item:
  575. - void **scroll_to_item** **(** :ref:`TreeItem<class_TreeItem>` item, :ref:`bool<class_bool>` center_on_item=false **)**
  576. Causes the ``Tree`` to jump to the specified :ref:`TreeItem<class_TreeItem>`.
  577. ----
  578. .. _class_Tree_method_set_column_clip_content:
  579. - void **set_column_clip_content** **(** :ref:`int<class_int>` column, :ref:`bool<class_bool>` enable **)**
  580. ----
  581. .. _class_Tree_method_set_column_custom_minimum_width:
  582. - void **set_column_custom_minimum_width** **(** :ref:`int<class_int>` column, :ref:`int<class_int>` min_width **)**
  583. Overrides the calculated minimum width of a column. It can be set to `0` to restore the default behavior. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to :ref:`Control.size_flags_stretch_ratio<class_Control_property_size_flags_stretch_ratio>`.
  584. ----
  585. .. _class_Tree_method_set_column_expand:
  586. - void **set_column_expand** **(** :ref:`int<class_int>` column, :ref:`bool<class_bool>` expand **)**
  587. If ``true``, the column will have the "Expand" flag of :ref:`Control<class_Control>`. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to :ref:`Control.size_flags_stretch_ratio<class_Control_property_size_flags_stretch_ratio>`.
  588. ----
  589. .. _class_Tree_method_set_column_expand_ratio:
  590. - void **set_column_expand_ratio** **(** :ref:`int<class_int>` column, :ref:`int<class_int>` ratio **)**
  591. ----
  592. .. _class_Tree_method_set_column_title:
  593. - void **set_column_title** **(** :ref:`int<class_int>` column, :ref:`String<class_String>` title **)**
  594. Sets the title of a column.
  595. ----
  596. .. _class_Tree_method_set_column_title_direction:
  597. - void **set_column_title_direction** **(** :ref:`int<class_int>` column, :ref:`TextDirection<enum_Control_TextDirection>` direction **)**
  598. Sets column title base writing direction.
  599. ----
  600. .. _class_Tree_method_set_column_title_language:
  601. - void **set_column_title_language** **(** :ref:`int<class_int>` column, :ref:`String<class_String>` language **)**
  602. Sets language code of column title used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
  603. ----
  604. .. _class_Tree_method_set_column_title_opentype_feature:
  605. - void **set_column_title_opentype_feature** **(** :ref:`int<class_int>` column, :ref:`String<class_String>` tag, :ref:`int<class_int>` value **)**
  606. Sets OpenType feature ``tag`` for the column title.
  607. Theme Property Descriptions
  608. ---------------------------
  609. .. _class_Tree_theme_color_children_hl_line_color:
  610. - :ref:`Color<class_Color>` **children_hl_line_color**
  611. +-----------+--------------------------------+
  612. | *Default* | ``Color(0.27, 0.27, 0.27, 1)`` |
  613. +-----------+--------------------------------+
  614. The :ref:`Color<class_Color>` of the relationship lines between the selected :ref:`TreeItem<class_TreeItem>` and its children.
  615. ----
  616. .. _class_Tree_theme_color_custom_button_font_highlight:
  617. - :ref:`Color<class_Color>` **custom_button_font_highlight**
  618. +-----------+--------------------------------+
  619. | *Default* | ``Color(0.95, 0.95, 0.95, 1)`` |
  620. +-----------+--------------------------------+
  621. Text :ref:`Color<class_Color>` for a :ref:`TreeItem.CELL_MODE_CUSTOM<class_TreeItem_constant_CELL_MODE_CUSTOM>` mode cell when it's hovered.
  622. ----
  623. .. _class_Tree_theme_color_drop_position_color:
  624. - :ref:`Color<class_Color>` **drop_position_color**
  625. +-----------+---------------------------+
  626. | *Default* | ``Color(1, 0.3, 0.2, 1)`` |
  627. +-----------+---------------------------+
  628. :ref:`Color<class_Color>` used to draw possible drop locations. See :ref:`DropModeFlags<enum_Tree_DropModeFlags>` constants for further description of drop locations.
  629. ----
  630. .. _class_Tree_theme_color_font_color:
  631. - :ref:`Color<class_Color>` **font_color**
  632. +-----------+-----------------------------+
  633. | *Default* | ``Color(0.7, 0.7, 0.7, 1)`` |
  634. +-----------+-----------------------------+
  635. Default text :ref:`Color<class_Color>` of the item.
  636. ----
  637. .. _class_Tree_theme_color_font_outline_color:
  638. - :ref:`Color<class_Color>` **font_outline_color**
  639. +-----------+-----------------------+
  640. | *Default* | ``Color(1, 1, 1, 1)`` |
  641. +-----------+-----------------------+
  642. The tint of text outline of the item.
  643. ----
  644. .. _class_Tree_theme_color_font_selected_color:
  645. - :ref:`Color<class_Color>` **font_selected_color**
  646. +-----------+-----------------------+
  647. | *Default* | ``Color(1, 1, 1, 1)`` |
  648. +-----------+-----------------------+
  649. Text :ref:`Color<class_Color>` used when the item is selected.
  650. ----
  651. .. _class_Tree_theme_color_guide_color:
  652. - :ref:`Color<class_Color>` **guide_color**
  653. +-----------+--------------------------------+
  654. | *Default* | ``Color(0.7, 0.7, 0.7, 0.25)`` |
  655. +-----------+--------------------------------+
  656. :ref:`Color<class_Color>` of the guideline.
  657. ----
  658. .. _class_Tree_theme_color_parent_hl_line_color:
  659. - :ref:`Color<class_Color>` **parent_hl_line_color**
  660. +-----------+--------------------------------+
  661. | *Default* | ``Color(0.27, 0.27, 0.27, 1)`` |
  662. +-----------+--------------------------------+
  663. The :ref:`Color<class_Color>` of the relationship lines between the selected :ref:`TreeItem<class_TreeItem>` and its parents.
  664. ----
  665. .. _class_Tree_theme_color_relationship_line_color:
  666. - :ref:`Color<class_Color>` **relationship_line_color**
  667. +-----------+--------------------------------+
  668. | *Default* | ``Color(0.27, 0.27, 0.27, 1)`` |
  669. +-----------+--------------------------------+
  670. The default :ref:`Color<class_Color>` of the relationship lines.
  671. ----
  672. .. _class_Tree_theme_color_title_button_color:
  673. - :ref:`Color<class_Color>` **title_button_color**
  674. +-----------+-----------------------------------+
  675. | *Default* | ``Color(0.875, 0.875, 0.875, 1)`` |
  676. +-----------+-----------------------------------+
  677. Default text :ref:`Color<class_Color>` of the title button.
  678. ----
  679. .. _class_Tree_theme_constant_button_margin:
  680. - :ref:`int<class_int>` **button_margin**
  681. +-----------+-------+
  682. | *Default* | ``4`` |
  683. +-----------+-------+
  684. The horizontal space between each button in a cell.
  685. ----
  686. .. _class_Tree_theme_constant_children_hl_line_width:
  687. - :ref:`int<class_int>` **children_hl_line_width**
  688. +-----------+-------+
  689. | *Default* | ``1`` |
  690. +-----------+-------+
  691. The width of the relationship lines between the selected :ref:`TreeItem<class_TreeItem>` and its children.
  692. ----
  693. .. _class_Tree_theme_constant_draw_guides:
  694. - :ref:`int<class_int>` **draw_guides**
  695. +-----------+-------+
  696. | *Default* | ``1`` |
  697. +-----------+-------+
  698. Draws the guidelines if not zero, this acts as a boolean. The guideline is a horizontal line drawn at the bottom of each item.
  699. ----
  700. .. _class_Tree_theme_constant_draw_relationship_lines:
  701. - :ref:`int<class_int>` **draw_relationship_lines**
  702. +-----------+-------+
  703. | *Default* | ``0`` |
  704. +-----------+-------+
  705. Draws the relationship lines if not zero, this acts as a boolean. Relationship lines are drawn at the start of child items to show hierarchy.
  706. ----
  707. .. _class_Tree_theme_constant_hseparation:
  708. - :ref:`int<class_int>` **hseparation**
  709. +-----------+-------+
  710. | *Default* | ``4`` |
  711. +-----------+-------+
  712. The horizontal space between item cells. This is also used as the margin at the start of an item when folding is disabled.
  713. ----
  714. .. _class_Tree_theme_constant_item_margin:
  715. - :ref:`int<class_int>` **item_margin**
  716. +-----------+--------+
  717. | *Default* | ``16`` |
  718. +-----------+--------+
  719. The horizontal margin at the start of an item. This is used when folding is enabled for the item.
  720. ----
  721. .. _class_Tree_theme_constant_outline_size:
  722. - :ref:`int<class_int>` **outline_size**
  723. +-----------+-------+
  724. | *Default* | ``0`` |
  725. +-----------+-------+
  726. The size of the text outline.
  727. ----
  728. .. _class_Tree_theme_constant_parent_hl_line_margin:
  729. - :ref:`int<class_int>` **parent_hl_line_margin**
  730. +-----------+-------+
  731. | *Default* | ``0`` |
  732. +-----------+-------+
  733. The space between the parent relationship lines for the selected :ref:`TreeItem<class_TreeItem>` and the relationship lines to its siblings that are not selected.
  734. ----
  735. .. _class_Tree_theme_constant_parent_hl_line_width:
  736. - :ref:`int<class_int>` **parent_hl_line_width**
  737. +-----------+-------+
  738. | *Default* | ``1`` |
  739. +-----------+-------+
  740. The width of the relationship lines between the selected :ref:`TreeItem<class_TreeItem>` and its parents.
  741. ----
  742. .. _class_Tree_theme_constant_relationship_line_width:
  743. - :ref:`int<class_int>` **relationship_line_width**
  744. +-----------+-------+
  745. | *Default* | ``1`` |
  746. +-----------+-------+
  747. The default width of the relationship lines.
  748. ----
  749. .. _class_Tree_theme_constant_scroll_border:
  750. - :ref:`int<class_int>` **scroll_border**
  751. +-----------+-------+
  752. | *Default* | ``4`` |
  753. +-----------+-------+
  754. The maximum distance between the mouse cursor and the control's border to trigger border scrolling when dragging.
  755. ----
  756. .. _class_Tree_theme_constant_scroll_speed:
  757. - :ref:`int<class_int>` **scroll_speed**
  758. +-----------+--------+
  759. | *Default* | ``12`` |
  760. +-----------+--------+
  761. The speed of border scrolling.
  762. ----
  763. .. _class_Tree_theme_constant_vseparation:
  764. - :ref:`int<class_int>` **vseparation**
  765. +-----------+-------+
  766. | *Default* | ``4`` |
  767. +-----------+-------+
  768. The vertical padding inside each item, i.e. the distance between the item's content and top/bottom border.
  769. ----
  770. .. _class_Tree_theme_font_font:
  771. - :ref:`Font<class_Font>` **font**
  772. :ref:`Font<class_Font>` of the item's text.
  773. ----
  774. .. _class_Tree_theme_font_title_button_font:
  775. - :ref:`Font<class_Font>` **title_button_font**
  776. :ref:`Font<class_Font>` of the title button's text.
  777. ----
  778. .. _class_Tree_theme_font_size_font_size:
  779. - :ref:`int<class_int>` **font_size**
  780. Font size of the item's text.
  781. ----
  782. .. _class_Tree_theme_icon_arrow:
  783. - :ref:`Texture2D<class_Texture2D>` **arrow**
  784. The arrow icon used when a foldable item is not collapsed.
  785. ----
  786. .. _class_Tree_theme_icon_arrow_collapsed:
  787. - :ref:`Texture2D<class_Texture2D>` **arrow_collapsed**
  788. The arrow icon used when a foldable item is collapsed (for left-to-right layouts).
  789. ----
  790. .. _class_Tree_theme_icon_arrow_collapsed_mirrored:
  791. - :ref:`Texture2D<class_Texture2D>` **arrow_collapsed_mirrored**
  792. The arrow icon used when a foldable item is collapsed (for right-to-left layouts).
  793. ----
  794. .. _class_Tree_theme_icon_checked:
  795. - :ref:`Texture2D<class_Texture2D>` **checked**
  796. The check icon to display when the :ref:`TreeItem.CELL_MODE_CHECK<class_TreeItem_constant_CELL_MODE_CHECK>` mode cell is checked.
  797. ----
  798. .. _class_Tree_theme_icon_indeterminate:
  799. - :ref:`Texture2D<class_Texture2D>` **indeterminate**
  800. The check icon to display when the :ref:`TreeItem.CELL_MODE_CHECK<class_TreeItem_constant_CELL_MODE_CHECK>` mode cell is indeterminate.
  801. ----
  802. .. _class_Tree_theme_icon_select_arrow:
  803. - :ref:`Texture2D<class_Texture2D>` **select_arrow**
  804. The arrow icon to display for the :ref:`TreeItem.CELL_MODE_RANGE<class_TreeItem_constant_CELL_MODE_RANGE>` mode cell.
  805. ----
  806. .. _class_Tree_theme_icon_unchecked:
  807. - :ref:`Texture2D<class_Texture2D>` **unchecked**
  808. The check icon to display when the :ref:`TreeItem.CELL_MODE_CHECK<class_TreeItem_constant_CELL_MODE_CHECK>` mode cell is unchecked.
  809. ----
  810. .. _class_Tree_theme_icon_updown:
  811. - :ref:`Texture2D<class_Texture2D>` **updown**
  812. The updown arrow icon to display for the :ref:`TreeItem.CELL_MODE_RANGE<class_TreeItem_constant_CELL_MODE_RANGE>` mode cell.
  813. ----
  814. .. _class_Tree_theme_style_bg:
  815. - :ref:`StyleBox<class_StyleBox>` **bg**
  816. Default :ref:`StyleBox<class_StyleBox>` for the ``Tree``, i.e. used when the control is not being focused.
  817. ----
  818. .. _class_Tree_theme_style_bg_focus:
  819. - :ref:`StyleBox<class_StyleBox>` **bg_focus**
  820. :ref:`StyleBox<class_StyleBox>` used when the ``Tree`` is being focused.
  821. ----
  822. .. _class_Tree_theme_style_button_pressed:
  823. - :ref:`StyleBox<class_StyleBox>` **button_pressed**
  824. :ref:`StyleBox<class_StyleBox>` used when a button in the tree is pressed.
  825. ----
  826. .. _class_Tree_theme_style_cursor:
  827. - :ref:`StyleBox<class_StyleBox>` **cursor**
  828. :ref:`StyleBox<class_StyleBox>` used for the cursor, when the ``Tree`` is being focused.
  829. ----
  830. .. _class_Tree_theme_style_cursor_unfocused:
  831. - :ref:`StyleBox<class_StyleBox>` **cursor_unfocused**
  832. :ref:`StyleBox<class_StyleBox>` used for the cursor, when the ``Tree`` is not being focused.
  833. ----
  834. .. _class_Tree_theme_style_custom_button:
  835. - :ref:`StyleBox<class_StyleBox>` **custom_button**
  836. Default :ref:`StyleBox<class_StyleBox>` for a :ref:`TreeItem.CELL_MODE_CUSTOM<class_TreeItem_constant_CELL_MODE_CUSTOM>` mode cell.
  837. ----
  838. .. _class_Tree_theme_style_custom_button_hover:
  839. - :ref:`StyleBox<class_StyleBox>` **custom_button_hover**
  840. :ref:`StyleBox<class_StyleBox>` for a :ref:`TreeItem.CELL_MODE_CUSTOM<class_TreeItem_constant_CELL_MODE_CUSTOM>` mode cell when it's hovered.
  841. ----
  842. .. _class_Tree_theme_style_custom_button_pressed:
  843. - :ref:`StyleBox<class_StyleBox>` **custom_button_pressed**
  844. :ref:`StyleBox<class_StyleBox>` for a :ref:`TreeItem.CELL_MODE_CUSTOM<class_TreeItem_constant_CELL_MODE_CUSTOM>` mode cell when it's pressed.
  845. ----
  846. .. _class_Tree_theme_style_selected:
  847. - :ref:`StyleBox<class_StyleBox>` **selected**
  848. :ref:`StyleBox<class_StyleBox>` for the selected items, used when the ``Tree`` is not being focused.
  849. ----
  850. .. _class_Tree_theme_style_selected_focus:
  851. - :ref:`StyleBox<class_StyleBox>` **selected_focus**
  852. :ref:`StyleBox<class_StyleBox>` for the selected items, used when the ``Tree`` is being focused.
  853. ----
  854. .. _class_Tree_theme_style_title_button_hover:
  855. - :ref:`StyleBox<class_StyleBox>` **title_button_hover**
  856. :ref:`StyleBox<class_StyleBox>` used when the title button is being hovered.
  857. ----
  858. .. _class_Tree_theme_style_title_button_normal:
  859. - :ref:`StyleBox<class_StyleBox>` **title_button_normal**
  860. Default :ref:`StyleBox<class_StyleBox>` for the title button.
  861. ----
  862. .. _class_Tree_theme_style_title_button_pressed:
  863. - :ref:`StyleBox<class_StyleBox>` **title_button_pressed**
  864. :ref:`StyleBox<class_StyleBox>` used when the title button is being pressed.
  865. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  866. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  867. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  868. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  869. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  870. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`