Table of Contents

Class MenuItemBuilder

Namespace
SharpConsoleUI.Builders
Assembly
SharpConsoleUI.dll

Fluent builder for creating MenuItem instances with a hierarchical structure.

public class MenuItemBuilder
Inheritance
MenuItemBuilder
Inherited Members

Constructors

MenuItemBuilder(string)

Initializes a new MenuItemBuilder with the specified text.

public MenuItemBuilder(string text)

Parameters

text string

The text to display for this menu item.

Methods

AddItem(string, Action)

Adds a child menu item with text and action.

public MenuItemBuilder AddItem(string text, Action action)

Parameters

text string

The text to display for the child item.

action Action

The action to execute when selected.

Returns

MenuItemBuilder

AddItem(string, Action, Color)

Adds a child menu item with text, action, and custom foreground color.

public MenuItemBuilder AddItem(string text, Action action, Color foregroundColor)

Parameters

text string

The text to display for the child item.

action Action

The action to execute when selected.

foregroundColor Color

The custom foreground color for this item.

Returns

MenuItemBuilder

AddItem(string, Action<MenuItemBuilder>)

Adds a child menu item with nested subitems using a configuration action.

public MenuItemBuilder AddItem(string text, Action<MenuItemBuilder> configure)

Parameters

text string

The text to display for the child item.

configure Action<MenuItemBuilder>

Action to configure the child item's submenu.

Returns

MenuItemBuilder

AddItem(string, string, Action)

Adds a child menu item with text, shortcut, and action.

public MenuItemBuilder AddItem(string text, string shortcut, Action action)

Parameters

text string

The text to display for the child item.

shortcut string

The keyboard shortcut text (display only).

action Action

The action to execute when selected.

Returns

MenuItemBuilder

AddItem(string, string, Action, Color)

Adds a child menu item with text, shortcut, action, and custom foreground color.

public MenuItemBuilder AddItem(string text, string shortcut, Action action, Color foregroundColor)

Parameters

text string

The text to display for the child item.

shortcut string

The keyboard shortcut text (display only).

action Action

The action to execute when selected.

foregroundColor Color

The custom foreground color for this item.

Returns

MenuItemBuilder

AddSeparator()

Adds a separator line to the submenu.

public MenuItemBuilder AddSeparator()

Returns

MenuItemBuilder

Disabled()

Marks this menu item as disabled.

public MenuItemBuilder Disabled()

Returns

MenuItemBuilder

WithAction(Action)

Sets the action to execute when this menu item is selected.

public MenuItemBuilder WithAction(Action action)

Parameters

action Action

The action to execute.

Returns

MenuItemBuilder

WithForegroundColor(Color)

Sets a custom foreground color for this menu item.

public MenuItemBuilder WithForegroundColor(Color color)

Parameters

color Color

The foreground color to use.

Returns

MenuItemBuilder

WithShortcut(string)

Sets the keyboard shortcut text for this menu item (display only).

public MenuItemBuilder WithShortcut(string shortcut)

Parameters

shortcut string

The shortcut text to display (e.g., "Ctrl+S").

Returns

MenuItemBuilder

WithTag(object)

Sets user-defined data associated with this menu item.

public MenuItemBuilder WithTag(object tag)

Parameters

tag object

The user data to associate.

Returns

MenuItemBuilder