Class MenuItem
- Namespace
- SharpConsoleUI.Controls
- Assembly
- SharpConsoleUI.dll
Represents a menu item with support for hierarchical menu structures.
public class MenuItem
- Inheritance
-
MenuItem
- Inherited Members
Properties
Action
Gets or sets the action to execute when this menu item is selected. Not called for items with children (submenus).
public Action? Action { get; set; }
Property Value
Bounds
Gets or sets the screen-space bounds of this menu item for hit testing. Managed internally by MenuControl.
public Rectangle Bounds { get; }
Property Value
Children
Gets the list of child menu items (submenu).
public List<MenuItem> Children { get; }
Property Value
ForegroundColor
Gets or sets the custom foreground color for this menu item. If set, this color will be used instead of the default menu colors (unless item is disabled or highlighted).
public Color? ForegroundColor { get; set; }
Property Value
- Color?
HasChildren
Gets whether this menu item has any children (is a submenu).
public bool HasChildren { get; }
Property Value
IsEnabled
Gets or sets whether this menu item is enabled. Disabled items are shown but cannot be selected.
public bool IsEnabled { get; set; }
Property Value
IsOpen
Gets or sets whether this menu item's dropdown/submenu is currently open. Managed internally by MenuControl.
public bool IsOpen { get; }
Property Value
IsSeparator
Gets or sets whether this menu item is a separator (horizontal line).
public bool IsSeparator { get; set; }
Property Value
Parent
Gets or sets the parent menu item. Null for top-level items.
public MenuItem? Parent { get; }
Property Value
Shortcut
Gets or sets the keyboard shortcut text displayed on the right (display only, not handled by MenuControl). Example: "Ctrl+S", "Alt+F4"
public string? Shortcut { get; set; }
Property Value
Tag
Gets or sets user-defined data associated with this menu item.
public object? Tag { get; set; }
Property Value
Text
Gets or sets the display text for this menu item.
public string Text { get; set; }
Property Value
Methods
AddChild(MenuItem)
Adds a child menu item to this item's submenu.
public void AddChild(MenuItem item)
Parameters
itemMenuItemThe menu item to add as a child.
GetDepth()
Gets the depth level of this menu item in the hierarchy (0 for top-level).
public int GetDepth()
Returns
GetPath()
Gets the full hierarchical path of this menu item. Example: "File/Recent/Document1.txt"
public string GetPath()
Returns
- string
A forward-slash separated path string.
ToString()
Returns a string representation of this menu item for debugging.
public override string ToString()