Skip to content

Hex1bNode

Namespace: Hex1b

Assembly: Hex1b.dll

csharp
public abstract class Hex1bNode

Inheritance

ObjectHex1bNode

Properties

Bounds

The bounds assigned to this node after layout.

Returns: Rect

csharp
public Rect Bounds { get; set; }

ContentBounds

The bounds of this node's actual content for hit testing purposes. Defaults to . Override for nodes that position content within a larger layout area (e.g., AnchoredNode).

Returns: Rect

csharp
public virtual Rect ContentBounds { get; }

HeightHint

Hint for how this node should be sized vertically within its parent. Used by VStack to distribute height among children.

Returns: Nullable<SizeHint>

csharp
public SizeHint? HeightHint { get; set; }

HitTestBounds

Gets the bounds used for mouse hit testing. By default, returns the full Bounds. Override in nodes where only a portion of the bounds should respond to clicks (e.g., SplitterNode's divider).

Returns: Rect

csharp
public virtual Rect HitTestBounds { get; }

IsDirty

Whether this node needs to be re-rendered. New nodes start dirty. The framework clears this after each render frame.

Returns: Boolean

csharp
public bool IsDirty { get; }

IsFocusable

Returns true if this node can receive focus.

Returns: Boolean

csharp
public virtual bool IsFocusable { get; }

IsFocused

Gets or sets whether this node is currently focused. Only meaningful for focusable nodes (where IsFocusable is true).

Returns: Boolean

csharp
public virtual bool IsFocused { get; set; }

IsHovered

Gets or sets whether the mouse is currently hovering over this node. Set by Hex1bApp based on mouse position during each frame. Only set on focusable nodes (tracked via FocusRing hit testing).

Returns: Boolean

csharp
public virtual bool IsHovered { get; set; }

ManagesChildFocus

Returns true if this node manages focus for its children. When a parent manages focus, child containers should NOT set initial focus themselves. Container nodes like SplitterNode should override this to return true.

Returns: Boolean

csharp
public virtual bool ManagesChildFocus { get; }

MetricName

User-assigned or auto-generated metric name segment for this node. Combined with ancestor names to form the hierarchical metric path.

Returns: String

csharp
public string? MetricName { get; }

Parent

The parent node in the tree (set during reconciliation).

Returns: Hex1bNode

csharp
public Hex1bNode? Parent { get; set; }

PreferredCursorShape

Gets the preferred cursor shape when the mouse is over this node. Override this to customize cursor appearance (e.g., text input uses a bar cursor).

Returns: CursorShape

csharp
public virtual CursorShape PreferredCursorShape { get; }

PreviousBounds

The bounds from the previous frame, used for dirty region tracking. Before the first arrange, this will be an empty rect at (0,0).

Returns: Rect

csharp
public Rect PreviousBounds { get; }

WidthHint

Hint for how this node should be sized horizontally within its parent. Used by HStack to distribute width among children.

Returns: Nullable<SizeHint>

csharp
public SizeHint? WidthHint { get; set; }

Methods

Arrange(Rect)

Assigns final bounds to this node and arranges children. When per-node metrics are enabled, records the duration. Subclasses override to implement arranging logic. Call base.ArrangeCore(bounds) to save bounds and mark dirty on change.

Parameters:

csharp
public void Arrange(Rect bounds)

ArrangeCore(Rect)

Override this method to implement arranging logic for this node. The base implementation saves previous bounds, marks dirty on change, and sets bounds.

Parameters:

csharp
protected virtual void ArrangeCore(Rect bounds)

ConfigureDefaultBindings(InputBindingsBuilder)

Configures the default input bindings for this node type. Override in derived classes to add default key bindings. These bindings can be inspected and modified by the user's callback.

Parameters:

csharp
public virtual void ConfigureDefaultBindings(InputBindingsBuilder bindings)

GetChildren()

Gets the direct children of this node. Used for input routing and tree traversal. Container nodes should override this to return their children.

Returns: IEnumerable<Hex1bNode>

csharp
public virtual IEnumerable<Hex1bNode> GetChildren()

GetFocusableNodes()

Gets all focusable nodes in this subtree (including this node if focusable).

Returns: IEnumerable<Hex1bNode>

csharp
public virtual IEnumerable<Hex1bNode> GetFocusableNodes()

HandleInput(Hex1bEvent)

Handles an input event (after bindings have been checked). Override this in nodes to handle input that wasn't matched by any binding.

Parameters:

  • inputEvent (Hex1bEvent): The input event to handle (keyboard or mouse).

Returns: InputResult

Handled if the input was consumed, NotHandled otherwise.

csharp
public virtual InputResult HandleInput(Hex1bEvent inputEvent)

HandleMouseClick(int, int, Hex1bMouseEvent)

Handles a mouse click event (after mouse bindings have been checked). Override this in nodes to handle clicks that weren't matched by any mouse binding. The coordinates in the event are local to this node's bounds (0,0 is top-left of node).

Parameters:

  • localX (Int32): The X coordinate relative to this node's bounds.
  • localY (Int32): The Y coordinate relative to this node's bounds.
  • mouseEvent (Hex1bMouseEvent): The original mouse event (with absolute coordinates).

Returns: InputResult

Handled if the click was consumed, NotHandled otherwise.

csharp
public virtual InputResult HandleMouseClick(int localX, int localY, Hex1bMouseEvent mouseEvent)

HandlePasteAsync(Hex1bPasteEvent)

Handles a bracketed paste event asynchronously. Override this in nodes that can consume pasted content (e.g., text editors, file drop zones).

Parameters:

Returns: Task<InputResult>

if the paste was consumed, to bubble the paste to ancestor nodes.

csharp
public virtual Task<InputResult> HandlePasteAsync(Hex1bPasteEvent pasteEvent)

MarkDirty()

Marks this node as needing re-rendering. Call this when internal state changes that don't flow through widget reconciliation.

csharp
public void MarkDirty()

Measure(Constraints)

Measures the desired size of this node given the constraints. When per-node metrics are enabled, records the duration. Subclasses override to implement measuring logic.

Parameters:

Returns: Size

csharp
public Size Measure(Constraints constraints)

MeasureCore(Constraints)

Override this method to implement measuring logic for this node.

Parameters:

Returns: Size

csharp
protected abstract Size MeasureCore(Constraints constraints)

NeedsRender()

Checks if this node or any of its descendants need rendering. Used to determine if a subtree can be skipped entirely.

Returns: Boolean

csharp
public bool NeedsRender()

Render(Hex1bRenderContext)

Renders the node to the given context.

Parameters:

csharp
public abstract void Render(Hex1bRenderContext context)

SyncFocusIndex()

Syncs internal focus tracking to match the current IsFocused state of child nodes. Called after externally setting focus on a child node. Container nodes should override this to update their internal focus index.

csharp
public virtual void SyncFocusIndex()

Released under the MIT License.