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 [get_root].
Returns [code]true[/code] if the column titles are being shown.
Clears the tree. This removes all items.
Create an item in the tree and add it as the last child of [code]parent[/code]. If [code]parent[/code] is [code]null[/code], it will be added as the root's last child, or it'll be the the root itself if the tree is empty.
Makes the currently selected item visible. This will scroll the tree to make sure the selected item is visible.
Returns the column index under the given point.
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].
If [member drop_mode_flags] includes [constant DROP_MODE_INBETWEEN], returns -1 if [code]position[/code] is the upper part of a tree item at that position, 1 for the lower part, and additionally 0 for the middle part if [member drop_mode_flags] includes [constant DROP_MODE_ON_ITEM].
Otherwise, returns 0. If there are no tree items at [code]position[/code], returns -100.
Returns the currently edited item. This is only available for custom cell mode.
Returns the column for the currently edited item. This is only available for custom cell mode.
Returns the rectangle area for the specified item. If column 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.
Returns the last pressed button's index.
Returns the tree's root item.
Returns the current scrolling position.
Returns the currently selected item.
Returns the current selection's column.
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 [code]DROP_MODE_*[/code] constants. Once dropping is done, reverts to [constant DROP_MODE_DISABLED]. Setting this during [method Control.can_drop_data] is recommended.
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 [code]SELECT_*[/code] 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 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 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].
Allows selection of a single item at a time.
Allows selection of multiple items at the same time.