Skip to content
Eduard Gushchin edited this page Jul 1, 2026 · 3 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.Tree
Namespace Electron2D
Kind class
Category UI and Text

Overview

Displays selectable Electron2D.TreeItem objects in a hierarchy.

Syntax

public class Electron2D.Tree : Electron2D.Control

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Supported / Parity verified
Out of profile: no
Godot reference: Tree

Hierarchical UI control with root item, hidden-root mode, columns, titles, visible-item hit testing, selection state, collapsed descendants and selection/collapse signals.

Remarks

Tree stores one root item and any number of descendant items. It can hide the root row, select visible items by pointer input and expose the current selected item through Electron2D.Tree.GetSelected.

The 0.1.0 Preview implementation focuses on runtime tree display and selection. Drag-and-drop, editing controls and scrolling are planned for later UI tasks.

Thread Safety

This type is not synchronized. Create and mutate trees on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control
  • Electron2D.TreeItem

Members

Member Kind Summary
AllowReselect Property Gets or sets whether selecting the current item again emits signals.
AllowRmbSelect Property Gets or sets whether right mouse button input may select rows.
AutoTooltip Property Gets or sets whether automatic tooltip lookup is enabled.
ColumnTitlesVisible Property Gets or sets whether column title rows are visible.
Columns Property Gets or sets the number of columns stored by the tree.
HideFolding Property Gets or sets whether folding arrows are hidden.
HideRoot Property Gets or sets whether the root item is hidden from visible traversal.
SelectMode Property Gets or sets the current selection mode.
Electron2D.Tree() Constructor Initializes a new instance of the Electron2D.Tree class.
Clear() Method Removes all items and clears selection.
CreateItem(Electron2D.TreeItem, System.Int32) Method Creates an item in this tree.
DeselectAll() Method Clears every selected item.
GetColumnTitle(System.Int32) Method Gets the title of one column.
GetItemAtPosition(Electron2D.Vector2) Method Gets the visible item at a local position.
GetRoot() Method Gets the root item.
GetSelected() Method Gets the currently selected item.
GetSelectedColumn() Method Gets the selected column.
SetColumnTitle(System.Int32, System.String) Method Sets the title of one column.
_Draw() Method Draws the visible tree rows.
_GetMinimumSize() Method Gets the minimum size requested by this tree.
_GuiInput(Electron2D.InputEvent) Method Handles GUI input routed to this tree.

Member Details

AllowReselect

Kind: Property

public System.Boolean AllowReselect { get; set; }

Summary

Gets or sets whether selecting the current item again emits signals.

Remarks

This affects pointer and programmatic selection through Electron2D.TreeItem.Select(System.Int32,System.Boolean).

Value

true to allow repeated selection signals; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.GetSelected

AllowRmbSelect

Kind: Property

public System.Boolean AllowRmbSelect { get; set; }

Summary

Gets or sets whether right mouse button input may select rows.

Remarks

Right-click selection is useful before opening a context menu.

Value

true to allow right-click selection; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree._GuiInput(Electron2D.InputEvent)

AutoTooltip

Kind: Property

public System.Boolean AutoTooltip { get; set; }

Summary

Gets or sets whether automatic tooltip lookup is enabled.

Remarks

The preview stores this flag. Full per-cell tooltip lookup is planned with richer editor UI tasks.

Value

true when item text may be used as tooltip fallback; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control.TooltipText

ColumnTitlesVisible

Kind: Property

public System.Boolean ColumnTitlesVisible { get; set; }

Summary

Gets or sets whether column title rows are visible.

Remarks

Column titles are drawn only when this flag is enabled.

Value

true to reserve a title row; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.SetColumnTitle(System.Int32,System.String)

Columns

Kind: Property

public System.Int32 Columns { get; set; }

Summary

Gets or sets the number of columns stored by the tree.

Remarks

Existing item cell data is preserved when reducing the column count, but drawing and hit-testing use the current value.

Value

A positive column count. The default is 1.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is less than 1.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.SetColumnTitle(System.Int32,System.String)

HideFolding

Kind: Property

public System.Boolean HideFolding { get; set; }

Summary

Gets or sets whether folding arrows are hidden.

Remarks

The preview stores this flag and keeps collapse state functional.

Value

true to hide folding affordances; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TreeItem.SetCollapsed(System.Boolean)

HideRoot

Kind: Property

public System.Boolean HideRoot { get; set; }

Summary

Gets or sets whether the root item is hidden from visible traversal.

Remarks

Hidden root items still own children and can be returned by Electron2D.Tree.GetRoot.

Value

true to hide the root row; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.GetRoot

SelectMode

Kind: Property

public Electron2D.Tree.SelectModeEnum SelectMode { get; set; }

Summary

Gets or sets the current selection mode.

Remarks

Switching away from multi selection clears extra selected cells.

Value

The current Electron2D.Tree.SelectModeEnum. The default is Electron2D.Tree.SelectModeEnum.Single.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TreeItem.Select(System.Int32,System.Boolean)

Electron2D.Tree()

Kind: Constructor

public Electron2D.Tree()

Summary

Initializes a new instance of the Electron2D.Tree class.

Remarks

The constructor enables focus, clips hit-testing and registers item_selected, multi_selected, item_activated and item_collapsed signals.

Thread Safety

This constructor is not synchronized. Call it from the main scene thread.

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree

Clear()

Kind: Method

public System.Void Clear()()

Summary

Removes all items and clears selection.

Remarks

Column titles and tree configuration are preserved.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.CreateItem(Electron2D.TreeItem,System.Int32)

CreateItem(Electron2D.TreeItem, System.Int32)

Kind: Method

public Electron2D.TreeItem CreateItem(Electron2D.TreeItem, System.Int32)(Electron2D.TreeItem parent, System.Int32 index)

Summary

Creates an item in this tree.

Remarks

The first call with a null parent creates the root. Later calls with a null parent append a child under the root.

Parameters

  • parent: The parent item, or null to create or append under the root.
  • index: The insertion index, or -1 to append.

Returns

The created Electron2D.TreeItem.

Exceptions

  • System.ArgumentException: Thrown when parent belongs to another tree.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.GetRoot

DeselectAll()

Kind: Method

public System.Void DeselectAll()()

Summary

Clears every selected item.

Remarks

This method clears both tree cursor state and per-item selected flags.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.GetSelected

GetColumnTitle(System.Int32)

Kind: Method

public System.String GetColumnTitle(System.Int32)(System.Int32 column)

Summary

Gets the title of one column.

Remarks

Titles are drawn only when Electron2D.Tree.ColumnTitlesVisible is true.

Parameters

  • column: The zero-based column index.

Returns

The column title, or an empty string when no title is stored.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when column is outside the current column range.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.SetColumnTitle(System.Int32,System.String)

GetItemAtPosition(Electron2D.Vector2)

Kind: Method

public Electron2D.TreeItem GetItemAtPosition(Electron2D.Vector2)(Electron2D.Vector2 position)

Summary

Gets the visible item at a local position.

Remarks

The root row is skipped when Electron2D.Tree.HideRoot is true.

Parameters

  • position: The local tree position.

Returns

The visible item at the row, or null when no row exists there.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TreeItem.GetNextVisible

GetRoot()

Kind: Method

public Electron2D.TreeItem GetRoot()()

Summary

Gets the root item.

Remarks

The root can be hidden from visible traversal by Electron2D.Tree.HideRoot.

Returns

The root item, or null when the tree is empty.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.CreateItem(Electron2D.TreeItem,System.Int32)

GetSelected()

Kind: Method

public Electron2D.TreeItem GetSelected()()

Summary

Gets the currently selected item.

Remarks

In multi selection mode this returns the most recent cursor item.

Returns

The selected item, or null when nothing is selected.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.GetSelectedColumn

GetSelectedColumn()

Kind: Method

public System.Int32 GetSelectedColumn()()

Summary

Gets the selected column.

Remarks

Row selection still records the column that received input.

Returns

The selected column, or -1 when nothing is selected.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.GetSelected

SetColumnTitle(System.Int32, System.String)

Kind: Method

public System.Void SetColumnTitle(System.Int32, System.String)(System.Int32 column, System.String title)

Summary

Sets the title of one column.

Remarks

Assigning a title queues a redraw.

Parameters

  • column: The zero-based column index.
  • title: The column title.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when column is outside the current column range.
  • System.ArgumentNullException: Thrown when title is null.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Tree.GetColumnTitle(System.Int32)

_Draw()

Kind: Method

public System.Void _Draw()()

Summary

Draws the visible tree rows.

Remarks

Text drawing is skipped when no theme font is available.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CanvasItem.DrawRect(Electron2D.Rect2,Electron2D.Color,System.Boolean,System.Single,System.Boolean)

_GetMinimumSize()

Kind: Method

public Electron2D.Vector2 _GetMinimumSize()()

Summary

Gets the minimum size requested by this tree.

Remarks

The minimum height changes when items collapse or when the root is hidden.

Returns

A conservative size for the current visible row count.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control.GetMinimumSize

_GuiInput(Electron2D.InputEvent)

Kind: Method

public System.Void _GuiInput(Electron2D.InputEvent)(Electron2D.InputEvent inputEvent)

Summary

Handles GUI input routed to this tree.

Remarks

Mouse and touch press select visible items. Double-click and activation keys emit item_activated.

Parameters

  • inputEvent: The input event delivered by the viewport.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control._GuiInput(Electron2D.InputEvent)

Clone this wiki locally