.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead. .. _class_Tree: Tree ==== **Inherits:** :ref:`Control` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Control to show a tree of items. Member Functions ---------------- +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`are_column_titles_visible` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Object` | :ref:`create_item` **(** :ref:`Object` parent=null **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`ensure_cursor_is_visible` **(** **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`get_allow_reselect` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`get_allow_rmb_select` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_column_at_pos` **(** :ref:`Vector2` pos **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_column_title` **(** :ref:`int` column **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_column_width` **(** :ref:`int` column **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_columns` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Rect2` | :ref:`get_custom_popup_rect` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_drop_mode_flags` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`TreeItem` | :ref:`get_edited` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_edited_column` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Rect2` | :ref:`get_item_area_rect` **(** :ref:`Object` item, :ref:`int` column=null **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`TreeItem` | :ref:`get_item_at_pos` **(** :ref:`Vector2` pos **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`TreeItem` | :ref:`get_next_selected` **(** :ref:`Object` from **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_pressed_button` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`TreeItem` | :ref:`get_root` **(** **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_scroll` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`TreeItem` | :ref:`get_selected` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_selected_column` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_folding_hidden` **(** **)** const | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_allow_reselect` **(** :ref:`bool` allow **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_allow_rmb_select` **(** :ref:`bool` allow **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_column_expand` **(** :ref:`int` column, :ref:`bool` expand **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_column_min_width` **(** :ref:`int` column, :ref:`int` min_width **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_column_title` **(** :ref:`int` column, :ref:`String` title **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_column_titles_visible` **(** :ref:`bool` visible **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_columns` **(** :ref:`int` amount **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_drop_mode_flags` **(** :ref:`int` flags **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_hide_folding` **(** :ref:`bool` hide **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_hide_root` **(** :ref:`bool` enable **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_select_mode` **(** :ref:`int` mode **)** | +----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ Signals ------- - **button_pressed** **(** :ref:`Object` item, :ref:`int` column, :ref:`int` id **)** Emitted when a button on the tree was pressed (see :ref:`TreeItem.add_button`). - **cell_selected** **(** **)** Emitted when a cell is selected. - **column_title_pressed** **(** :ref:`int` column **)** - **custom_popup_edited** **(** :ref:`bool` arrow_clicked **)** Emitted when a cell with the ``CELL_MODE_CUSTOM`` is clicked to be edited. - **empty_tree_rmb_selected** **(** :ref:`Vector2` pos **)** Emitted when the right mouse button is pressed if RMB selection is active and the tree is empty. - **item_activated** **(** **)** Emitted when an item is activated (double-clicked). - **item_collapsed** **(** :ref:`Object` item **)** Emitted when an item is collapsed by a click on the folding arrow. - **item_edited** **(** **)** Emitted when an item is editted. - **item_rmb_selected** **(** :ref:`Vector2` pos **)** Emitted when an item is selected with right mouse button. - **item_selected** **(** **)** Emitted when an item is selected with right mouse button. - **multi_selected** **(** :ref:`Object` item, :ref:`int` column, :ref:`bool` selected **)** Numeric Constants ----------------- - **SELECT_SINGLE** = **0** - **SELECT_ROW** = **1** - **SELECT_MULTI** = **2** - **DROP_MODE_DISABLED** = **0** - **DROP_MODE_ON_ITEM** = **1** - **DROP_MODE_INBETWEEN** = **2** Description ----------- 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 structural displaying and interactions. Trees are built via code, using :ref:`TreeItem` objects to create the structure. They have a single root but multiple root can be simulated if a dummy hidden root is added. :: func _ready(): var tree = Tree.new() var root = tree.create_item() tree.set_hide_root(true) var child1 = tree.create_item(root) var child2 = tree.create_item(root) var subchild1 = tree.create_item(child1) subchild1.set_text(0, "Subchild1") Member Function Description --------------------------- .. _class_Tree_are_column_titles_visible: - :ref:`bool` **are_column_titles_visible** **(** **)** const Get whether the column titles are being shown. .. _class_Tree_clear: - void **clear** **(** **)** Clear the tree. This erases all of the items. .. _class_Tree_create_item: - :ref:`Object` **create_item** **(** :ref:`Object` parent=null **)** Create an item in the tree and add it as the last child of ``parent``. If parent is not given, it will be added as the last child of the root, or it'll the be the root itself if the tree is empty. Create an item in the tree and add it as the last child of ``parent``. If parent is not given, it will be added as the last child of the root, or it'll the be the root itself if the tree is empty. .. _class_Tree_ensure_cursor_is_visible: - void **ensure_cursor_is_visible** **(** **)** Make the current selected item visible. This will scroll the tree to make sure the selected item is in sight. .. _class_Tree_get_allow_rmb_select: - :ref:`bool` **get_allow_rmb_select** **(** **)** const Get whether a right click can select items. .. _class_Tree_get_column_at_pos: - :ref:`int` **get_column_at_pos** **(** :ref:`Vector2` pos **)** const Get the column index under the given point. .. _class_Tree_get_column_title: - :ref:`String` **get_column_title** **(** :ref:`int` column **)** const Get the title of the given column. .. _class_Tree_get_column_width: - :ref:`int` **get_column_width** **(** :ref:`int` column **)** const Get the width of the given column in pixels. .. _class_Tree_get_columns: - :ref:`int` **get_columns** **(** **)** const Get the amount of columns. .. _class_Tree_get_custom_popup_rect: - :ref:`Rect2` **get_custom_popup_rect** **(** **)** const Get the rectangle for custom popups. Helper to create custom cell controls that display a popup. See :ref:`TreeItem.set_cell_mode`. .. _class_Tree_get_drop_mode_flags: - :ref:`int` **get_drop_mode_flags** **(** **)** const Get the flags of the current drop mode. .. _class_Tree_get_edited: - :ref:`TreeItem` **get_edited** **(** **)** const Get the current edited item. This is only available for custom cell mode. .. _class_Tree_get_edited_column: - :ref:`int` **get_edited_column** **(** **)** const Get the column of the cell for the current edited icon. This is only available for custom cell mode. .. _class_Tree_get_item_area_rect: - :ref:`Rect2` **get_item_area_rect** **(** :ref:`Object` item, :ref:`int` column=null **)** const Get the rectangle area of the the specified item. If column is specified, only get the position and size of that column, otherwise get the rectangle containing all columns. Get the rectangle area of the the specified item. If column is specified, only get the position and size of that column, otherwise get the rectangle containing all columns. .. _class_Tree_get_item_at_pos: - :ref:`TreeItem` **get_item_at_pos** **(** :ref:`Vector2` pos **)** const Get the tree item at the specified position (relative to the tree origin position). .. _class_Tree_get_next_selected: - :ref:`TreeItem` **get_next_selected** **(** :ref:`Object` from **)** Get the next selected item after the given one. Get the next selected item after the given one. .. _class_Tree_get_pressed_button: - :ref:`int` **get_pressed_button** **(** **)** const Get the index of the last pressed button. .. _class_Tree_get_root: - :ref:`TreeItem` **get_root** **(** **)** Get the root item of the tree. .. _class_Tree_get_scroll: - :ref:`Vector2` **get_scroll** **(** **)** const Get the current scrolling position. .. _class_Tree_get_selected: - :ref:`TreeItem` **get_selected** **(** **)** const Get the currently selected item. .. _class_Tree_get_selected_column: - :ref:`int` **get_selected_column** **(** **)** const Get the column number of the current selection. .. _class_Tree_get_single_select_cell_editing_only_when_already_selected: - :ref:`bool` **get_single_select_cell_editing_only_when_already_selected** **(** **)** const Get whether the editing of a cell should only happen when it is already selected. .. _class_Tree_is_folding_hidden: - :ref:`bool` **is_folding_hidden** **(** **)** const Get whether the folding arrow is hidden. .. _class_Tree_set_allow_rmb_select: - void **set_allow_rmb_select** **(** :ref:`bool` allow **)** Set whether or not a right mouse button click can select items. .. _class_Tree_set_column_expand: - void **set_column_expand** **(** :ref:`int` column, :ref:`bool` expand **)** Set whether a column will have the "Expand" flag of :ref:`Control`. .. _class_Tree_set_column_min_width: - void **set_column_min_width** **(** :ref:`int` column, :ref:`int` min_width **)** Set the minimum width of a column. .. _class_Tree_set_column_title: - void **set_column_title** **(** :ref:`int` column, :ref:`String` title **)** Set the title of a column. .. _class_Tree_set_column_titles_visible: - void **set_column_titles_visible** **(** :ref:`bool` visible **)** Set whether the column titles visibility. .. _class_Tree_set_columns: - void **set_columns** **(** :ref:`int` amount **)** Set the amount of columns. .. _class_Tree_set_drop_mode_flags: - void **set_drop_mode_flags** **(** :ref:`int` flags **)** Set the drop mode as an OR combination of flags. See ``DROP_MODE\_\*`` constants. .. _class_Tree_set_hide_folding: - void **set_hide_folding** **(** :ref:`bool` hide **)** Set whether the folding arrow should be hidden. .. _class_Tree_set_hide_root: - void **set_hide_root** **(** :ref:`bool` enable **)** Set whether the root of the tree should be hidden. .. _class_Tree_set_select_mode: - void **set_select_mode** **(** :ref:`int` mode **)** Set the selection mode. Use one of the ``SELECT\_\*`` constants. .. _class_Tree_set_single_select_cell_editing_only_when_already_selected: - void **set_single_select_cell_editing_only_when_already_selected** **(** :ref:`bool` enable **)** Set whether the editing of a cell should only happen when it is already selected.