API ReferenceSandbox.UI

TreeView<T>class

A virtualized tree over your own objects. You give it roots and a way to get children; it keeps a flat list of the rows that are reachable through open nodes and only ever creates enough row panels to fill the viewport. Give `Sandbox.UI.TreeView.GetChildren` lists or arrays and scrolling allocates nothing.

objectBaseTreeViewTreeView<T>
Namespace
Sandbox.UI
Assembly
Sandbox.Engine
Declaration
public class Sandbox.UI.TreeView<T> : Sandbox.UI.BaseTreeView

Constructors1

Showing 1 constructors

Methods26

Showing 26 methods

protected virtual void BindRow(int row, Sandbox.UI.TreeRow panel)PROTECTEDVIRTUAL

ParameterTypeDescription
rowint
panelTreeRow
Returns:void

protected virtual void BuildRows()PROTECTEDVIRTUAL

Returns:void

protected virtual bool CanRenameRow(int row)PROTECTEDVIRTUAL

ParameterTypeDescription
rowint
Returns:bool

protected virtual void CheckForChanges()PROTECTEDVIRTUAL

Returns:void

protected virtual void ClearSelectionInternal()PROTECTEDVIRTUAL

Returns:void

public void Close(T item, bool recursive = False)PUBLIC

ParameterTypeDescription
itemT
recursive = Falsebool
Returns:void

public bool ExpandPathTo(T item)PUBLIC

ParameterTypeDescription
itemT
Returns:bool

public int GetItemRow(T item)PUBLIC

ParameterTypeDescription
itemT
Returns:int

public T GetRowItem(int row)PUBLIC

The item at a visible row.

ParameterTypeDescription
rowint
Returns:T

public void Highlight(T item)PUBLIC

ParameterTypeDescription
itemT
Returns:void

public bool IsOpen(T item)PUBLIC

ParameterTypeDescription
itemT
Returns:bool

protected virtual bool IsRowSelected(int row)PROTECTEDVIRTUAL

ParameterTypeDescription
rowint
Returns:bool

public bool IsSelected(T item)PUBLIC

ParameterTypeDescription
itemT
Returns:bool

protected virtual void OnRowActivated(int row)PROTECTEDVIRTUAL

ParameterTypeDescription
rowint
Returns:void

protected virtual void OnRowContextMenu(int row)PROTECTEDVIRTUAL

ParameterTypeDescription
rowint
Returns:void

protected virtual void OnRowDropped(int targetRow, int sourceRow)PROTECTEDVIRTUAL

ParameterTypeDescription
targetRowint
sourceRowint
Returns:void

protected virtual void OnRowRenamed(int row, string text)PROTECTEDVIRTUAL

ParameterTypeDescription
rowint
textstring
Returns:void

protected virtual void OnSelectionFinished()PROTECTEDVIRTUAL

Returns:void

public void Open(T item, bool recursive = False)PUBLIC

ParameterTypeDescription
itemT
recursive = Falsebool
Returns:void

public void ScrollTo(T item)PUBLIC

ParameterTypeDescription
itemT
Returns:void

public void Select(T item, bool add = False)PUBLIC

ParameterTypeDescription
itemT
add = Falsebool
Returns:void

protected virtual void SetRowOpen(int row, bool open, bool recursive)PROTECTEDVIRTUAL

ParameterTypeDescription
rowint
openbool
recursivebool
Returns:void

protected virtual void SetRowSelected(int row, bool selected)PROTECTEDVIRTUAL

ParameterTypeDescription
rowint
selectedbool
Returns:void

public void Toggle(T item, bool recursive = False)PUBLIC

ParameterTypeDescription
itemT
recursive = Falsebool
Returns:void

Properties20

Showing 20 properties

public System.Func`2<T,bool> Sandbox.UI.TreeView<T>.CanDrag { get; set; }PUBLICGETSET

Can this item be dragged? Setting this makes rows draggable.

Returns:Func<T,bool>

public System.Func`2<T,bool> Sandbox.UI.TreeView<T>.CanExpand { get; set; }PUBLICGETSET

Whether an item can be expanded. Optional - without it `Sandbox.UI.TreeView.GetChildren` is asked.

Returns:Func<T,bool>

public System.Func`2<T,bool> Sandbox.UI.TreeView<T>.CanRename { get; set; }PUBLICGETSET

Whether F2 can rename an item. Optional - without it any item can when `Sandbox.UI.TreeView.OnRename` is set.

Returns:Func<T,bool>

public System.Collections.Generic.IEqualityComparer`1<T> Sandbox.UI.TreeView<T>.Comparer { get; set; }PUBLICGETSET

How items are compared for open and selected state. Set before adding anything.

Returns:IEqualityComparer<T>

public T Sandbox.UI.TreeView<T>.CursorItem { get; set; }PUBLICGETSET

The item under the keyboard cursor, or default.

Returns:T

public System.Func`2<T,System.Collections.Generic.IEnumerable`1<T>> Sandbox.UI.TreeView<T>.GetChildren { get; set; }PUBLICGETSET

The children of an item. Return a list or array to avoid allocating enumerators.

Returns:Func<T,IEnumerable<T>>

public System.Func`2<T,float> Sandbox.UI.TreeView<T>.GetHeight { get; set; }PUBLICGETSET

Height of a specific item's row. Optional - without it every row is `Sandbox.UI.BaseTreeView.RowHeight`.

Returns:Func<T,float>

public System.Func`2<T,T> Sandbox.UI.TreeView<T>.GetParent { get; set; }PUBLICGETSET

The parent of an item, or default for a root. Optional, but without it opening the path to an item is a search down from the roots, which walks a lazy tree into existence.

Returns:Func<T,T>

public System.Func`2<T,string> Sandbox.UI.TreeView<T>.GetTooltip { get; set; }PUBLICGETSET

Hover text for an item.

Returns:Func<T,string>

public System.Action`1<T> Sandbox.UI.TreeView<T>.OnActivate { get; set; }PUBLICGETSET

Double click or enter on an item. A double click opens a closed branch first when `Sandbox.UI.BaseTreeView.ExpandOnDoubleClick` is enabled.

Returns:Action<T>

public System.Action`1<T> Sandbox.UI.TreeView<T>.OnContextMenu { get; set; }PUBLICGETSET

Right click on an item. Build and show whatever menu you like.

Returns:Action<T>

public System.Action`2<T,T> Sandbox.UI.TreeView<T>.OnItemDropped { get; set; }PUBLICGETSET

A dragged item was dropped on a target item, or on empty space when the target is default.

Returns:Action<T,T>

public System.Action`2<T,string> Sandbox.UI.TreeView<T>.OnRename { get; set; }PUBLICGETSET

The user finished renaming an item in place. Apply it to your data.

Returns:Action<T,string>

public System.Action`2<Sandbox.UI.TreeRow,T> Sandbox.UI.TreeView<T>.OnRow { get; set; }PUBLICGETSETPER-FRAME

Fill a row panel from its item. Called when a row scrolls in or the tree refreshes, never per frame. Rows are reused, so create extra panels once and update them here.

Returns:Action<TreeRow,T>

public System.Action`1<T> Sandbox.UI.TreeView<T>.OnSelect { get; set; }PUBLICGETSET

The cursor item after any selection change.

Returns:Action<T>

public System.Action Sandbox.UI.TreeView<T>.OnSelectionChanged { get; set; }PUBLICGETSET

Any change to `Sandbox.UI.TreeView.Selection`.

Returns:Action

public System.Collections.Generic.IReadOnlyCollection`1<T> Sandbox.UI.TreeView<T>.OpenItems { get; set; }PUBLICGETSET

The items that are open.

Returns:IReadOnlyCollection<T>

public System.Collections.Generic.IEnumerable`1<T> Sandbox.UI.TreeView<T>.Roots { get; set; }PUBLICGETSET

The top level items. Pass a list or array and additions and removals are picked up automatically.

Returns:IEnumerable<T>

public Microsoft.AspNetCore.Components.RenderFragment`1<T> Sandbox.UI.TreeView<T>.Row { get; set; }PUBLICGETSET

Razor template for a row's content. Re-rendered on every bind, which allocates - prefer `Sandbox.UI.TreeView.OnRow` where that matters.

Returns:RenderFragment<T>

public System.Collections.Generic.IReadOnlyCollection`1<T> Sandbox.UI.TreeView<T>.Selection { get; set; }PUBLICGETSET

The selected items.

Returns:IReadOnlyCollection<T>

On this page

Constructorspublic TreeView<T>()Methodsprotected virtual System.Void BindRow(System.Int32 row, Sandbox.UI.TreeRow panel)protected virtual System.Void BuildRows()protected virtual System.Boolean CanRenameRow(System.Int32 row)protected virtual System.Void CheckForChanges()protected virtual System.Void ClearSelectionInternal()public System.Void Close(T item, System.Boolean recursive = False)public System.Boolean ExpandPathTo(T item)public System.Int32 GetItemRow(T item)public T GetRowItem(System.Int32 row)public System.Void Highlight(T item)public System.Boolean IsOpen(T item)protected virtual System.Boolean IsRowSelected(System.Int32 row)public System.Boolean IsSelected(T item)protected virtual System.Void OnRowActivated(System.Int32 row)protected virtual System.Void OnRowContextMenu(System.Int32 row)protected virtual System.Void OnRowDropped(System.Int32 targetRow, System.Int32 sourceRow)protected virtual System.Void OnRowRenamed(System.Int32 row, System.String text)protected virtual System.Void OnSelectionFinished()public System.Void Open(T item, System.Boolean recursive = False)public System.Void Refresh()public System.Void Refresh(T item)public System.Void ScrollTo(T item)public System.Void Select(T item, System.Boolean add = False)protected virtual System.Void SetRowOpen(System.Int32 row, System.Boolean open, System.Boolean recursive)protected virtual System.Void SetRowSelected(System.Int32 row, System.Boolean selected)public System.Void Toggle(T item, System.Boolean recursive = False)Propertiespublic System.Func`2<T,System.Boolean> Sandbox.UI.TreeView<T>.CanDrag { get; set; }public System.Func`2<T,System.Boolean> Sandbox.UI.TreeView<T>.CanExpand { get; set; }public System.Func`2<T,System.Boolean> Sandbox.UI.TreeView<T>.CanRename { get; set; }public System.Collections.Generic.IEqualityComparer`1<T> Sandbox.UI.TreeView<T>.Comparer { get; set; }public T Sandbox.UI.TreeView<T>.CursorItem { get; set; }public System.Func`2<T,System.Collections.Generic.IEnumerable`1<T>> Sandbox.UI.TreeView<T>.GetChildren { get; set; }public System.Func`2<T,System.Single> Sandbox.UI.TreeView<T>.GetHeight { get; set; }public System.Func`2<T,T> Sandbox.UI.TreeView<T>.GetParent { get; set; }public System.Func`2<T,System.String> Sandbox.UI.TreeView<T>.GetTooltip { get; set; }public System.Action`1<T> Sandbox.UI.TreeView<T>.OnActivate { get; set; }public System.Action`1<T> Sandbox.UI.TreeView<T>.OnContextMenu { get; set; }public System.Action`2<T,T> Sandbox.UI.TreeView<T>.OnItemDropped { get; set; }public System.Action`2<T,System.String> Sandbox.UI.TreeView<T>.OnRename { get; set; }public System.Action`2<Sandbox.UI.TreeRow,T> Sandbox.UI.TreeView<T>.OnRow { get; set; }public System.Action`1<T> Sandbox.UI.TreeView<T>.OnSelect { get; set; }public System.Action Sandbox.UI.TreeView<T>.OnSelectionChanged { get; set; }public System.Collections.Generic.IReadOnlyCollection`1<T> Sandbox.UI.TreeView<T>.OpenItems { get; set; }public System.Collections.Generic.IEnumerable`1<T> Sandbox.UI.TreeView<T>.Roots { get; set; }public Microsoft.AspNetCore.Components.RenderFragment`1<T> Sandbox.UI.TreeView<T>.Row { get; set; }public System.Collections.Generic.IReadOnlyCollection`1<T> Sandbox.UI.TreeView<T>.Selection { get; set; }Metadata