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]
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 parent is not given, it will be added as the root's last child, or it'll the be 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 [code]DROP_MODE_INBETWEEN[/code], 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 [code]DROP_MODE_ON_ITEM[/code].
Otherwise, returns 0. If there are no tree item 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].
Set the minimum width of a column.
Set 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 amount of columns.
The drop mode as an OR combination of flags. See [code]DROP_MODE_*[/code] constants. Once dropping is done, reverts to [code]DROP_MODE_DISABLED[/code]. Setting this during [method can_drop_data] is recommended.
If [code]true[/code] the folding arrow is hidden.
If [code]true[/code] the tree's root is hidden.
Allow 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 [code]CELL_MODE_CUSTOM[/code] is clicked to be edited.
Emitted when the right mouse button is pressed if RMB selection is active and the tree is empty.
Emitted when an item is activated (double-clicked).
Emitted when an item is collapsed by a click on the folding arrow.
Emitted when an item 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 right mouse button.
Emitted when an item is selected with right mouse button.
Emitted instead of [code]item_selected[/code] when [code]select_mode[/code] is [code]SELECT_MULTI[/code].
Allow selection of a single item at a time.
Allow selection of multiple items at the same time.