MenuNode
Namespace: Hex1b
Assembly: Hex1b.dll
Render node for MenuWidget. Context-aware rendering: renders as a trigger in MenuBar, or as a submenu item in a parent Menu. When opened, pushes its content to the PopupStack.
public sealed class MenuNode : Hex1bNode, ILayoutProviderInheritance
Implements
Properties
Accelerator
The accelerator character for this menu (uppercase).
Returns: Nullable<Char>
public char? Accelerator { get; set; }AcceleratorIndex
The index of the accelerator character in the label.
Returns: Int32
public int AcceleratorIndex { get; set; }ChildAccelerators
The computed accelerators for child items.
Returns: List<IMenuChild, Char>, Int32>>
public List<(IMenuChild Child, char? Accelerator, int Index)> ChildAccelerators { get; set; }ChildNodes
Reconciled child nodes (populated when menu is opened).
Returns: List<Hex1bNode>
public List<Hex1bNode> ChildNodes { get; set; }Children
The children of this menu.
Returns: IReadOnlyList<IMenuChild>
public IReadOnlyList<IMenuChild> Children { get; set; }ClipMode
The clip mode for this layout region.
Returns: ClipMode
public ClipMode ClipMode { get; set; }ClipRect
The effective clipping rectangle for this layout region.
Returns: Rect
public Rect ClipRect { get; }FocusedChildIndex
The currently focused child index.
Returns: Int32
public int FocusedChildIndex { get; set; }IsFocusable
Returns true if this node can receive focus.
Returns: Boolean
public override bool IsFocusable { get; }IsFocused
Gets or sets whether this node is currently focused. Only meaningful for focusable nodes (where IsFocusable is true).
Returns: Boolean
public override 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
public override bool IsHovered { get; set; }IsOpen
Whether this menu is currently open (has pushed content to PopupStack).
Returns: Boolean
public bool IsOpen { get; set; }IsSelected
Whether this menu is currently selected (highlighted). Selection controls visual styling and is separate from focus. A menu can be selected even when focus moves to its child popup.
Returns: Boolean
public bool IsSelected { get; set; }Label
The display label for the menu.
Returns: String
public string Label { 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
public override bool ManagesChildFocus { get; }ParentLayoutProvider
The parent layout provider, if any. Set when this provider becomes the current layout provider and there was already one active. Used to ensure nested clipping works correctly.
Returns: ILayoutProvider
public ILayoutProvider? ParentLayoutProvider { get; set; }RenderWidth
The width to render when displayed as a submenu item (set by parent MenuNode).
Returns: Int32
public int RenderWidth { get; set; }SourceWidget
The source widget that was reconciled into this node.
Returns: MenuWidget
public MenuWidget? SourceWidget { get; set; }Methods
ClipString(int, int, string)
Clips a string that starts at the given position, returning only the visible portion. Implementations should also consult the ParentLayoutProvider if present.
Parameters:
x(Int32): Starting absolute X position.y(Int32): Absolute Y position.text(String): The text to potentially clip.
Returns: ValueTuple<Int32, String>
A tuple containing:
- adjustedX: The X position to start rendering (may be > x if left-clipped)
- clippedText: The portion of text that should be rendered (may be empty)
public (int adjustedX, string clippedText) ClipString(int x, int y, string text)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:
bindings(InputBindingsBuilder): The builder to add bindings to.
public override 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>
public override IEnumerable<Hex1bNode> GetChildren()GetFocusableNodes()
Gets all focusable nodes in this subtree (including this node if focusable).
Returns: IEnumerable<Hex1bNode>
public override IEnumerable<Hex1bNode> GetFocusableNodes()MeasureCore(Constraints)
Override this method to implement measuring logic for this node.
Parameters:
constraints(Constraints):
Returns: Size
protected override Size MeasureCore(Constraints constraints)Render(Hex1bRenderContext)
Renders the node to the given context.
Parameters:
context(Hex1bRenderContext):
public override void Render(Hex1bRenderContext context)ShouldRenderAt(int, int)
Determines if a character at the given absolute position should be rendered. Implementations should also check the ParentLayoutProvider if present.
Parameters:
x(Int32): Absolute X position in terminal coordinates.y(Int32): Absolute Y position in terminal coordinates.
Returns: Boolean
True if the character should be rendered, false if it should be clipped.
public bool ShouldRenderAt(int x, int y)