TreeItemWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A focusable tree item with label and optional icon. Supports lazy loading of children via OnExpanding callback.
public sealed record TreeItemWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<TreeItemWidget>Inheritance
Object → Hex1bWidget → TreeItemWidget
Implements
Constructors
TreeItemWidget(string)
A focusable tree item with label and optional icon. Supports lazy loading of children via OnExpanding callback.
Parameters:
Label(String): The display label for this tree item.
public TreeItemWidget(string Label)Properties
HasChildren
Hint that this item has children even if Children is empty. Used to show expand indicator for lazy-loaded items.
Returns: Boolean
public bool HasChildren { get; init; }IsExpanded
Whether this item is expanded to show children. Default is false (collapsed).
Returns: Boolean
public bool IsExpanded { get; init; }IsLoading
Whether this item is currently loading children. Default is false. When true, displays an animated spinner instead of the expand indicator.
Returns: Boolean
public bool IsLoading { get; init; }IsSelected
Whether this item is selected (for multi-select mode). Default is false.
Returns: Boolean
public bool IsSelected { get; init; }Label
The display label for this tree item.
Returns: String
public string Label { get; init; }Methods
Children(params TreeItemWidget[])
Sets the child items. Also sets HasChildren to true if children are provided.
Parameters:
children(TreeItemWidget[]):
Returns: TreeItemWidget
public TreeItemWidget Children(params TreeItemWidget[] children)Data<T>(T)
Associates typed data with this item. Retrieve with .
Parameters:
data(<T>): The data to associate with this item.
Returns: TreeItemWidget
A new TreeItemWidget with the data set.
public TreeItemWidget Data<T>(T data)Expanded(bool)
Sets whether this item is initially expanded.
Parameters:
expanded(Boolean):
Returns: TreeItemWidget
public TreeItemWidget Expanded(bool expanded = true)Icon(string)
Sets the icon/emoji prefix for this item.
Parameters:
icon(String):
Returns: TreeItemWidget
public TreeItemWidget Icon(string icon)Loading(bool)
Sets whether this item is currently loading children. When true, displays an animated spinner instead of the expand indicator.
Parameters:
loading(Boolean):
Returns: TreeItemWidget
public TreeItemWidget Loading(bool loading = true)OnActivated(Action<TreeItemActivatedEventArgs>)
Sets a synchronous handler called when this item is activated (Enter key).
Parameters:
handler(Action<TreeItemActivatedEventArgs>):
Returns: TreeItemWidget
public TreeItemWidget OnActivated(Action<TreeItemActivatedEventArgs> handler)OnActivated(Func<TreeItemActivatedEventArgs, Task>)
Sets an asynchronous handler called when this item is activated (Enter key or double-click).
Parameters:
handler(Func<TreeItemActivatedEventArgs, Task>):
Returns: TreeItemWidget
public TreeItemWidget OnActivated(Func<TreeItemActivatedEventArgs, Task> handler)OnClicked(Action<TreeItemClickedEventArgs>)
Sets a synchronous handler called when this item is clicked (single-click).
Parameters:
handler(Action<TreeItemClickedEventArgs>):
Returns: TreeItemWidget
public TreeItemWidget OnClicked(Action<TreeItemClickedEventArgs> handler)OnClicked(Func<TreeItemClickedEventArgs, Task>)
Sets an asynchronous handler called when this item is clicked (single-click).
Parameters:
handler(Func<TreeItemClickedEventArgs, Task>):
Returns: TreeItemWidget
public TreeItemWidget OnClicked(Func<TreeItemClickedEventArgs, Task> handler)OnCollapsed(Action<TreeItemCollapsedEventArgs>)
Sets a synchronous handler called when this item is collapsed.
Parameters:
handler(Action<TreeItemCollapsedEventArgs>):
Returns: TreeItemWidget
public TreeItemWidget OnCollapsed(Action<TreeItemCollapsedEventArgs> handler)OnCollapsed(Func<TreeItemCollapsedEventArgs, Task>)
Sets an asynchronous handler called when this item is collapsed.
Parameters:
handler(Func<TreeItemCollapsedEventArgs, Task>):
Returns: TreeItemWidget
public TreeItemWidget OnCollapsed(Func<TreeItemCollapsedEventArgs, Task> handler)OnExpanded(Action<TreeItemExpandedEventArgs>)
Sets a synchronous handler called after this item is expanded.
Parameters:
handler(Action<TreeItemExpandedEventArgs>):
Returns: TreeItemWidget
public TreeItemWidget OnExpanded(Action<TreeItemExpandedEventArgs> handler)OnExpanded(Func<TreeItemExpandedEventArgs, Task>)
Sets an asynchronous handler called after this item is expanded.
Parameters:
handler(Func<TreeItemExpandedEventArgs, Task>):
Returns: TreeItemWidget
public TreeItemWidget OnExpanded(Func<TreeItemExpandedEventArgs, Task> handler)OnExpanding(Func<TreeItemExpandingEventArgs, IEnumerable<TreeItemWidget>>)
Sets a synchronous handler for lazy loading children when the item is expanded. Also sets HasChildren to true.
Parameters:
Returns: TreeItemWidget
public TreeItemWidget OnExpanding(Func<TreeItemExpandingEventArgs, IEnumerable<TreeItemWidget>> handler)OnExpanding(Func<TreeItemExpandingEventArgs, Task<IEnumerable<TreeItemWidget>>>)
Sets an asynchronous handler for lazy loading children when the item is expanded. Also sets HasChildren to true.
Parameters:
Returns: TreeItemWidget
public TreeItemWidget OnExpanding(Func<TreeItemExpandingEventArgs, Task<IEnumerable<TreeItemWidget>>> handler)Selected(bool)
Sets whether this item is selected (for multi-select mode).
Parameters:
selected(Boolean):
Returns: TreeItemWidget
public TreeItemWidget Selected(bool selected = true)Fields
ActivateActionId
Action ID for activating the tree item.
Returns: ActionId
public static readonly ActionId ActivateActionIdCollapseActionId
Action ID for collapsing the tree item.
Returns: ActionId
public static readonly ActionId CollapseActionIdExpandActionId
Action ID for expanding the tree item.
Returns: ActionId
public static readonly ActionId ExpandActionIdToggleActionId
Action ID for toggling selection or expand state.
Returns: ActionId
public static readonly ActionId ToggleActionId