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.
public sealed class FocusRingInheritance
Object → FocusRing
Properties
CapturedNode
Gets the node that has captured all input, or null if no capture is active.
Returns: Hex1bNode
public Hex1bNode? CapturedNode { get; }Focusables
Gets all focusable nodes in render order.
Returns: IReadOnlyList<Hex1bNode>
public IReadOnlyList<Hex1bNode> Focusables { get; }FocusedIndex
Gets the index of the currently focused node, or -1 if none.
Returns: Int32
public int FocusedIndex { get; }FocusedNode
Gets the currently focused node, or null if none.
Returns: Hex1bNode
public Hex1bNode? FocusedNode { get; }LastFocusChange
Debug log of the last focus change. Useful for testing.
Returns: String
public string? LastFocusChange { get; }LastFocusChangeGlobal
Global debug log of the last focus change across all FocusRing instances.
Returns: String
public static string? LastFocusChangeGlobal { get; set; }LastFocusDebug
Debug info from the last Focus call.
Returns: String
public string? LastFocusDebug { get; set; }LastHitTestDebug
Debug info from the last HitTest call.
Returns: String
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.
public void CaptureInput(Hex1bNode node)EnsureFocus()
Ensures the first focusable has focus if nothing is currently focused.
public void EnsureFocus()Focus(Hex1bNode)
Focuses a specific node if it's in the ring.
Parameters:
node(Hex1bNode):
Returns: Boolean
True if the node was found and focused.
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.
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.
public bool FocusPrevious()FocusWhere(Func<Hex1bNode, bool>)
Focuses the first node in the ring that matches the predicate.
Parameters:
predicate(Func<Hex1bNode, Boolean>): A function that returns true for the node to focus.
Returns: Boolean
True if a matching node was found and focused, false otherwise.
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:
Returns: Hex1bNode
The focusable node at the position, or null if none.
public Hex1bNode? HitTest(int x, int y)Rebuild(Hex1bNode?)
Rebuilds the focus ring from the given root node. Call this after each render.
Parameters:
root(Hex1bNode):
public void Rebuild(Hex1bNode? root)ReleaseCapture()
Releases input capture, returning to normal input routing.
public void ReleaseCapture()