Control to show a tree of items. 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. Trees are built via code, using [TreeItem] objects to create the structure. They have a single root but multiple roots can be simulated if a dummy hidden root is added. [codeblock] 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") [/codeblock] To iterate over all the [TreeItem] objects in a [Tree] object, use [method TreeItem.get_next] and [method TreeItem.get_children] after getting the root through [method get_root]. You can use [method Object.free] on a [TreeItem] to remove it from the [Tree]. Returns [code]true[/code] if the column titles are being shown. Clears the tree. This removes all items. Creates an item in the tree and adds it as a child of [code]parent[/code]. If [code]parent[/code] is [code]null[/code], the root item will be the parent, or the new item will be the root itself if the tree is empty. The new item will be the [code]idx[/code]th child of parent, or it will be the last child if there are not enough siblings. Edits the selected tree item as if it was clicked. The item must be set editable with [method TreeItem.set_editable]. Returns [code]true[/code] if the item could be edited. Fails if no item is selected. Makes the currently focused cell visible. This will scroll the tree if necessary. In [constant SELECT_ROW] mode, this will not do horizontal scrolling, as all the cells in the selected row is focused logically. [b]Note:[/b] Despite the name of this method, the focus cursor itself is only visible in [constant SELECT_MULTI] mode. Returns the column index at [code]position[/code], or -1 if no item is there. Returns the column's title. Returns the column's width in pixels. Returns the rectangle for custom popups. Helper to create custom cell controls that display a popup. See [method TreeItem.set_cell_mode]. Returns the drop section at [code]position[/code], or -100 if no item is there. Values -1, 0, or 1 will be returned for the "above item", "on item", and "below item" drop sections, respectively. See [enum DropModeFlags] for a description of each drop section. To get the item which the returned drop section is relative to, use [method get_item_at_position]. Returns the currently edited item. Can be used with [signal item_edited] to get the item that was modified. [codeblock] func _ready(): $Tree.item_edited.connect(on_Tree_item_edited) func on_Tree_item_edited(): print($Tree.get_edited()) # This item just got edited (e.g. checked). [/codeblock] Returns the column for the currently edited item. Returns the rectangle area for the specified item. If [code]column[/code] is specified, only get the position and size of that column, otherwise get the rectangle containing all columns. Returns the tree item at the specified position (relative to the tree origin position). Returns the next selected item after the given one, or [code]null[/code] if the end is reached. If [code]from[/code] is [code]null[/code], this returns the first selected item. Returns the last pressed button's index. Returns the tree's root item, or [code]null[/code] if the tree is empty. Returns the current scrolling position. Returns the currently focused item, or [code]null[/code] if no item is focused. In [constant SELECT_ROW] and [constant SELECT_SINGLE] modes, the focused item is same as the selected item. In [constant SELECT_MULTI] mode, the focused item is the item under the focus cursor, not necessarily selected. To get the currently selected item(s), use [method get_next_selected]. Returns the currently focused column, or -1 if no column is focused. In [constant SELECT_SINGLE] mode, the focused column is the selected column. In [constant SELECT_ROW] mode, the focused column is always 0 if any item is selected. In [constant SELECT_MULTI] mode, the focused column is the column under the focus cursor, and there are not necessarily any column selected. To tell whether a column of an item is selected, use [method TreeItem.is_selected]. Causes the [Tree] to jump to the specified item. If [code]true[/code], the column will have the "Expand" flag of [Control]. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to [member Control.size_flags_stretch_ratio]. Sets the minimum width of a column. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to [member Control.size_flags_stretch_ratio]. Sets the title of a column. If [code]true[/code], column titles are visible. If [code]true[/code], the currently selected cell may be selected again. If [code]true[/code], a right mouse button click can select items. The number of columns. The drop mode as an OR combination of flags. See [enum DropModeFlags] constants. Once dropping is done, reverts to [constant DROP_MODE_DISABLED]. Setting this during [method Control.can_drop_data] is recommended. This controls the drop sections, i.e. the decision and drawing of possible drop locations based on the mouse position. If [code]true[/code], the folding arrow is hidden. If [code]true[/code], the tree's root is hidden. Allows single or multiple selection. See the [enum SelectMode] constants. Emitted when a button on the tree was pressed (see [method TreeItem.add_button]). Emitted when a cell is selected. Emitted when a column's title is pressed. Emitted when a cell with the [constant TreeItem.CELL_MODE_CUSTOM] is clicked to be edited. Emitted when the right mouse button is pressed in the empty space of the tree. Emitted when the right mouse button is pressed if right mouse button selection is active and the tree is empty. Emitted when an item's label is double-clicked. Emitted when an item is collapsed by a click on the folding arrow. Emitted when a custom button is pressed (i.e. in a [constant TreeItem.CELL_MODE_CUSTOM] mode cell). Emitted when an item's icon is double-clicked. Emitted when an item is edited. Emitted when an item is edited using the right mouse button. Emitted when an item is selected with the right mouse button. Emitted when an item is selected. Emitted instead of [code]item_selected[/code] if [code]select_mode[/code] is [constant SELECT_MULTI]. Emitted when a left mouse button click does not select any item. 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. 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. 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. 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. 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. The focus cursor is visible in this mode, the item or column under the cursor is not necessarily selected. Disables all drop sections, but still allows to detect the "on item" drop section by [method get_drop_section_at_position]. [b]Note:[/b] This is the default flag, it has no effect when combined with other flags. Enables the "on item" drop section. This drop section covers the entire item. When combined with [constant DROP_MODE_INBETWEEN], this drop section halves the height and stays centered vertically. 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. When combined with [constant DROP_MODE_ON_ITEM], these drop sections halves the height and stays on top / bottom accordingly. Text [Color] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's hovered. [Color] used to draw possible drop locations. See [enum DropModeFlags] constants for further description of drop locations. Default text [Color] of the item. Text [Color] used when the item is selected. [Color] of the guideline. [Color] of the relationship lines. Default text [Color] of the title button. The horizontal space between each button in a cell. Draws the guidelines if not zero, this acts as a boolean. The guideline is a horizontal line drawn at the bottom of each item. 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. The horizontal space between item cells. This is also used as the margin at the start of an item when folding is disabled. The horizontal margin at the start of an item. This is used when folding is enabled for the item. The maximum distance between the mouse cursor and the control's border to trigger border scrolling when dragging. The speed of border scrolling. The vertical padding inside each item, i.e. the distance between the item's content and top/bottom border. [Font] of the item's text. [Font] of the title button's text. The arrow icon used when a foldable item is not collapsed. The arrow icon used when a foldable item is collapsed. The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is checked. The arrow icon to display for the [constant TreeItem.CELL_MODE_RANGE] mode cell. The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is unchecked. The updown arrow icon to display for the [constant TreeItem.CELL_MODE_RANGE] mode cell. Default [StyleBox] for the [Tree], i.e. used when the control is not being focused. [StyleBox] used when the [Tree] is being focused. [StyleBox] used when a button in the tree is pressed. [StyleBox] used for the cursor, when the [Tree] is being focused. [StyleBox] used for the cursor, when the [Tree] is not being focused. Default [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell. [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's hovered. [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's pressed. [StyleBox] for the selected items, used when the [Tree] is not being focused. [StyleBox] for the selected items, used when the [Tree] is being focused. [StyleBox] used when the title button is being hovered. Default [StyleBox] for the title button. [StyleBox] used when the title button is being pressed.