Tree

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.

More...
@GodotBaseClass
struct Tree {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

Constants
enum Constants
DropModeFlags
enum DropModeFlags
SelectMode
enum SelectMode

Functions

_guiInput
void _guiInput(InputEvent arg0)
_popupSelect
void _popupSelect(long arg0)
_rangeClickTimeout
void _rangeClickTimeout()
_scrollMoved
void _scrollMoved(double arg0)
_textEditorEnter
void _textEditorEnter(String arg0)
_textEditorModalClose
void _textEditorModalClose()
_valueEditorChanged
void _valueEditorChanged(double arg0)
areColumnTitlesVisible
bool areColumnTitlesVisible()

Returns true if the column titles are being shown.

clear
void clear()

Clears the tree. This removes all items.

createItem
TreeItem createItem(GodotObject parent, long idx)

Creates an item in the tree and adds it as a child of parent. 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. The new item will be the idxth child of parent, or it will be the last child if there are not enough siblings.

editSelected
bool editSelected()

Edits the selected tree item as if it was clicked. The item must be set editable with TreeItem.setEditable. Returns true if the item could be edited. Fails if no item is selected.

ensureCursorIsVisible
void ensureCursorIsVisible()

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. Note: Despite the name of this method, the focus cursor itself is only visible in constant SELECT_MULTI mode.

getAllowReselect
bool getAllowReselect()
getAllowRmbSelect
bool getAllowRmbSelect()
getColumnAtPosition
long getColumnAtPosition(Vector2 position)

Returns the column index at position, or -1 if no item is there.

getColumnTitle
String getColumnTitle(long column)

Returns the column's title.

getColumnWidth
long getColumnWidth(long column)

Returns the column's width in pixels.

getColumns
long getColumns()
getCustomPopupRect
Rect2 getCustomPopupRect()

Returns the rectangle for custom popups. Helper to create custom cell controls that display a popup. See TreeItem.setCellMode.

getDropModeFlags
long getDropModeFlags()
getDropSectionAtPosition
long getDropSectionAtPosition(Vector2 position)

Returns the drop section at position, 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 dropmodeflags for a description of each drop section. To get the item which the returned drop section is relative to, use getItemAtPosition.

getEdited
TreeItem getEdited()

Returns the currently edited item. Can be used with itemEdited to get the item that was modified.

getEditedColumn
long getEditedColumn()

Returns the column for the currently edited item.

getItemAreaRect
Rect2 getItemAreaRect(GodotObject item, long column)

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.

getItemAtPosition
TreeItem getItemAtPosition(Vector2 position)

Returns the tree item at the specified position (relative to the tree origin position).

getNextSelected
TreeItem getNextSelected(GodotObject from)

Returns the next selected item after the given one, or null if the end is reached. If from is null, this returns the first selected item.

getPressedButton
long getPressedButton()

Returns the last pressed button's index.

getRoot
TreeItem getRoot()

Returns the tree's root item, or null if the tree is empty.

getScroll
Vector2 getScroll()

Returns the current scrolling position.

getSelectMode
Tree.SelectMode getSelectMode()
getSelected
TreeItem getSelected()

Returns the currently focused item, or null 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 getNextSelected.

getSelectedColumn
long getSelectedColumn()

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 TreeItem.isSelected.

isFoldingHidden
bool isFoldingHidden()
isRootHidden
bool isRootHidden()
opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(Tree other)
opEquals
bool opEquals(typeof(null) n)
scrollToItem
void scrollToItem(GodotObject item)

Causes the Tree to jump to the specified item.

setAllowReselect
void setAllowReselect(bool allow)
setAllowRmbSelect
void setAllowRmbSelect(bool allow)
setColumnExpand
void setColumnExpand(long column, bool expand)

If true, 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 Control.sizeFlagsStretchRatio.

setColumnMinWidth
void setColumnMinWidth(long column, long min_width)

Sets the minimum width of a column. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to Control.sizeFlagsStretchRatio.

setColumnTitle
void setColumnTitle(long column, String title)

Sets the title of a column.

setColumnTitlesVisible
void setColumnTitlesVisible(bool visible)

If true, column titles are visible.

setColumns
void setColumns(long amount)
setDropModeFlags
void setDropModeFlags(long flags)
setHideFolding
void setHideFolding(bool hide)
setHideRoot
void setHideRoot(bool enable)
setSelectMode
void setSelectMode(long mode)
toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

allowReselect
bool allowReselect [@property getter]
bool allowReselect [@property setter]

If true, the currently selected cell may be selected again.

allowRmbSelect
bool allowRmbSelect [@property getter]
bool allowRmbSelect [@property setter]

If true, a right mouse button click can select items.

columns
long columns [@property getter]
long columns [@property setter]

The number of columns.

dropModeFlags
long dropModeFlags [@property getter]
long dropModeFlags [@property setter]

The drop mode as an OR combination of flags. See dropmodeflags constants. Once dropping is done, reverts to constant DROP_MODE_DISABLED. Setting this during Control.canDropData is recommended. This controls the drop sections, i.e. the decision and drawing of possible drop locations based on the mouse position.

hideFolding
bool hideFolding [@property getter]
bool hideFolding [@property setter]

If true, the folding arrow is hidden.

hideRoot
bool hideRoot [@property getter]
bool hideRoot [@property setter]

If true, the tree's root is hidden.

selectMode
Tree.SelectMode selectMode [@property getter]
long selectMode [@property setter]

Allows single or multiple selection. See the selectmode constants.

Static functions

_new
Tree _new()

Construct a new instance of Tree. Note: use memnew!Tree instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Detailed Description

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")

To iterate over all the TreeItem objects in a Tree object, use TreeItem.getNext and TreeItem.getChildren after getting the root through getRoot. You can use GodotObject.free on a TreeItem to remove it from the Tree.

Meta