Skip to content

FocusRing ​

Namespace: Hex1b.Input

Assembly: Hex1b.dll

Maintains a flat ring of all focusable nodes from the current render. Built after each render by traversing GetFocusableNodes() on the root. Provides efficient navigation between focusables regardless of tree structure. Also tracks which node (if any) has captured all input.

csharp
public sealed class FocusRing

Inheritance ​

Object → FocusRing

Properties ​

CapturedNode ​

Gets the node that has captured all input, or null if no capture is active.

Returns: Hex1bNode

csharp
public Hex1bNode? CapturedNode { get; }

Focusables ​

Gets all focusable nodes in render order.

Returns: IReadOnlyList<Hex1bNode>

csharp
public IReadOnlyList<Hex1bNode> Focusables { get; }

FocusedIndex ​

Gets the index of the currently focused node, or -1 if none.

Returns: Int32

csharp
public int FocusedIndex { get; }

FocusedNode ​

Gets the currently focused node, or null if none.

Returns: Hex1bNode

csharp
public Hex1bNode? FocusedNode { get; }

LastFocusChange ​

Debug log of the last focus change. Useful for testing.

Returns: String

csharp
public string? LastFocusChange { get; }

LastFocusChangeGlobal ​

Global debug log of the last focus change across all FocusRing instances.

Returns: String

csharp
public static string? LastFocusChangeGlobal { get; set; }

LastFocusDebug ​

Debug info from the last Focus call.

Returns: String

csharp
public string? LastFocusDebug { get; set; }

LastHitTestDebug ​

Debug info from the last HitTest call.

Returns: String

csharp
public string? LastHitTestDebug { get; }

Methods ​

CaptureInput(Hex1bNode) ​

Captures all input to the specified node.

Parameters:

  • node (Hex1bNode): The node to capture input to. Must be in the focus ring.
csharp
public void CaptureInput(Hex1bNode node)

EnsureFocus() ​

Ensures the first focusable has focus if nothing is currently focused.

csharp
public void EnsureFocus()

Focus(Hex1bNode) ​

Focuses a specific node if it's in the ring.

Parameters:

Returns: Boolean

True if the node was found and focused.

csharp
public bool Focus(Hex1bNode node)

FocusNext() ​

Moves focus to the next focusable node in the ring. Wraps around from last to first.

Returns: Boolean

True if focus was moved, false if there are no focusables.

csharp
public bool FocusNext()

FocusPrevious() ​

Moves focus to the previous focusable node in the ring. Wraps around from first to last.

Returns: Boolean

True if focus was moved, false if there are no focusables.

csharp
public bool FocusPrevious()

FocusWhere(Func<Hex1bNode, bool>) ​

Focuses the first node in the ring that matches the predicate.

Parameters:

Returns: Boolean

True if a matching node was found and focused, false otherwise.

csharp
public bool FocusWhere(Func<Hex1bNode, bool> predicate)

HitTest(int, int) ​

Finds the focusable node at the given screen coordinates. Returns the topmost (last in render order) focusable node whose bounds contain the point.

Parameters:

  • x (Int32): X coordinate (0-based column).
  • y (Int32): Y coordinate (0-based row).

Returns: Hex1bNode

The focusable node at the position, or null if none.

csharp
public Hex1bNode? HitTest(int x, int y)

Rebuild(Hex1bNode?) ​

Rebuilds the focus ring from the given root node. Call this after each render.

Parameters:

csharp
public void Rebuild(Hex1bNode? root)

ReleaseCapture() ​

Releases input capture, returning to normal input routing.

csharp
public void ReleaseCapture()

Released under the MIT License.