MenuItem
ConsoleMonster.Interactive
An entry of a Menu: title, description, hotkey, icon, badge, state text, a disabled reason, and what it opens (an action, a submenu, a form, a selection, a page). Configure it with the chainable methods: item.Hotkey('r').Form(form).BadgeBy(() => RichText.Plain("24 tasks")).
Inheritance
- object
- MenuItem
Usage
Explore 120 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 57
- Method Menu.Find
- Property Menu.Items
- Property MenuContext.Item
- Extension method MenuItem.BadgeBy
- Extension method MenuItem.Choice
- Extension method MenuItem.Choices
- Extension method MenuItem.ChoicesBy
- Extension method MenuItem.CurrentBadge
- Extension method MenuItem.Description
- Extension method MenuItem.DetailBy
- Extension method MenuItem.DisabledReasonBy
- Extension method MenuItem.Form
- Extension method MenuItem.Hotkey
- Extension method MenuItem.Icon
- Extension method MenuItem.Kind
- Extension method MenuItem.Label
- Extension method MenuItem.Mark
- Extension method MenuItem.Maximum
- Extension method MenuItem.Minimum
- Extension method MenuItem.PageBy
- Extension method MenuItem.PreviewBy
- Extension method MenuItem.ReviewBy
- Extension method MenuItem.Run
- Extension method MenuItem.RunAsync
- Extension method MenuItem.Submenu
- Extension method MenuItem.WhenChanged
- Extension method MenuItem.WhenSubmitted
- Method MenuItem.MultiSelect``1
- Method MenuItem.Presets
- Method MenuItem.Select``1
- Method MenuItemFluent.BadgeBy
- Method MenuItemFluent.Choice
- Method MenuItemFluent.Choices
- Method MenuItemFluent.ChoicesBy
- Method MenuItemFluent.CurrentBadge
- Method MenuItemFluent.Description
- Method MenuItemFluent.DetailBy
- Method MenuItemFluent.DisabledReasonBy
- Method MenuItemFluent.Form
- Method MenuItemFluent.Hotkey
- Method MenuItemFluent.Icon
- Method MenuItemFluent.Kind
- Method MenuItemFluent.Label
- Method MenuItemFluent.Mark
- Method MenuItemFluent.Maximum
- Method MenuItemFluent.Minimum
- Method MenuItemFluent.PageBy
- Method MenuItemFluent.PreviewBy
- Method MenuItemFluent.ReviewBy
- Method MenuItemFluent.Run
- Method MenuItemFluent.RunAsync
- Method MenuItemFluent.Submenu
- Method MenuItemFluent.WhenChanged
- Method MenuItemFluent.WhenSubmitted
- Property MenuRunResult.NextActions
- Property ReviewModel.Fixes
- Method Ui.MenuItem
Accepted by parameters 63
- Extension method Menu.Item
- Extension method Menu.Items
- Method Menu.Add
- Method Menu.Item
- Method MenuContext.Open
- Method MenuFluent.Item
- Method MenuFluent.Items
- Extension method MenuItem.BadgeBy
- Extension method MenuItem.Choice
- Extension method MenuItem.Choices
- Extension method MenuItem.ChoicesBy
- Extension method MenuItem.CurrentBadge
- Extension method MenuItem.Description
- Extension method MenuItem.DetailBy
- Extension method MenuItem.DisabledReasonBy
- Extension method MenuItem.Form
- Extension method MenuItem.Form
- Extension method MenuItem.Hotkey
- Extension method MenuItem.Icon
- Extension method MenuItem.Kind
- Extension method MenuItem.Label
- Extension method MenuItem.Mark
- Extension method MenuItem.Maximum
- Extension method MenuItem.Minimum
- Extension method MenuItem.PageBy
- Extension method MenuItem.PreviewBy
- Extension method MenuItem.ReviewBy
- Extension method MenuItem.Run
- Extension method MenuItem.RunAsync
- Extension method MenuItem.Submenu
- Extension method MenuItem.WhenChanged
- Extension method MenuItem.WhenSubmitted
- Method MenuItemFluent.BadgeBy
- Method MenuItemFluent.Choice
- Method MenuItemFluent.Choices
- Method MenuItemFluent.ChoicesBy
- Method MenuItemFluent.CurrentBadge
- Method MenuItemFluent.Description
- Method MenuItemFluent.DetailBy
- Method MenuItemFluent.DisabledReasonBy
- Method MenuItemFluent.Form
- Method MenuItemFluent.Form
- Method MenuItemFluent.Hotkey
- Method MenuItemFluent.Icon
- Method MenuItemFluent.Kind
- Method MenuItemFluent.Label
- Method MenuItemFluent.Mark
- Method MenuItemFluent.Maximum
- Method MenuItemFluent.Minimum
- Method MenuItemFluent.PageBy
- Method MenuItemFluent.PreviewBy
- Method MenuItemFluent.ReviewBy
- Method MenuItemFluent.Run
- Method MenuItemFluent.RunAsync
- Method MenuItemFluent.Submenu
- Method MenuItemFluent.WhenChanged
- Method MenuItemFluent.WhenSubmitted
- Method MenuPreset.Selection
- Extension method MenuRunResult.NextAction
- Extension method MenuRunResult.NextActions
- Method MenuRunResultFluent.NextAction
- Method MenuRunResultFluent.NextActions
- Method ReviewModel.Problem
Constructors
Methods
public IReadOnlyList<T?> GetSelection<T>() #The selection as typed values.
Type Parameters
- T
- The value type.
Returns
IReadOnlyList<T?> The values.public string? IconText(IGlyphSet glyphs) #The icon text for a glyph set: the icon in its tier, else the free-text mark, else null.
Parameters
- glyphs ConsoleMonster.Glyphs.IGlyphSet
- The glyph set.
Returns
string? The icon text, or null.public MenuItem MultiSelect<T>(IEnumerable<T?> values, Func<T?, string>? display = null, Func<T?, string?>? group = null, Func<T?, IWidget?>? preview = null) #Makes the item pick several values.
Type Parameters
- T
- The value type.
Parameters
- values System.Collections.Generic.IEnumerable<T?>
- The values.
- display System.Func<T?, string>? = null
- The title of a value.
- group System.Func<T?, string?>? = null
- The group of a value.
- preview System.Func<T?, ConsoleMonster.Layout.IWidget?>? = null
- Preview content for a value.
public MenuItem Presets() #Makes the item list the menu's presets: the built-in ones (Menu.Presets of the root menu) first, marked as built in, then the saved ones. Enter applies one; Delete removes a saved one (Shell and Classic layouts; the Inline layout applies them only). A saved preset whose name matches a built-in one (ignoring case) is hidden.
public MenuItem Select<T>(IEnumerable<T?> values, Func<T?, string>? display = null, Func<T?, string?>? group = null, Func<T?, IWidget?>? preview = null) #Makes the item pick one value.
Type Parameters
- T
- The value type.
Parameters
- values System.Collections.Generic.IEnumerable<T?>
- The values.
- display System.Func<T?, string>? = null
- The title of a value.
- group System.Func<T?, string?>? = null
- The group of a value.
- preview System.Func<T?, ConsoleMonster.Layout.IWidget?>? = null
- Preview content for a value.
public void SetSelection(IEnumerable<object?> values) #Sets the selected values of a selection item (pre-selection, presets, programmatic changes).
Parameters
- values System.Collections.Generic.IEnumerable<object?>
- The values.
public override string ToString() #Returns a string that represents the current object.
Returns
string A string that represents the current object.Inherited Methods
Properties
public string? Mark { get; set; } #A short mark before the title (one or two cells), as free text. Setting it clears MenuItem.Icon.
public Icon Icon { get; set; } #An icon catalog key (see Icons) resolved for the glyph tier (shapes in Full, WGL4 in Basic, ASCII in Ascii). Setting it clears MenuItem.Mark.
public Func<RichText?>? Badge { get; set; } #Fluent("BadgeBy")Computes the badge (right-aligned tag) each time the menu is drawn.
public Func<string?>? Detail { get; set; } #Fluent("DetailBy")Computes the state text ("24 selected") each time the menu is drawn.
public Func<string?>? DisabledReason { get; set; } #Fluent("DisabledReasonBy")Computes why the item is unavailable (null when available).
public Func<MenuContext, CancellationToken, Task>? ActionAsync { get; set; } #Fluent("RunAsync")The asynchronous action of an action item (runs without blocking the screen; Esc cancels it).
public Action<MenuContext, FormResult>? OnSubmit { get; set; } #Fluent("WhenSubmitted")Called when the form is submitted.
public Func<MenuContext, IWidget>? Page { get; set; } #Fluent("PageBy")Builds the content of a page item.
public Func<Choice, IWidget?>? Preview { get; set; } #Fluent("PreviewBy")Preview content for the focused choice of a selection item.
public Func<MenuContext, CancellationToken, Task<IEnumerable<Choice>>>? LoadChoices { get; set; } #Fluent("ChoicesBy")Loads the choices of a selection item asynchronously (a spinner shows meanwhile; Ctrl+R reloads).
public Func<MenuContext, ReviewModel>? Review { get; set; } #Fluent("ReviewBy")Builds the review of a review item each time it is drawn.
public Action<MenuContext>? OnChange { get; set; } #Fluent("WhenChanged")Called when the selection of a selection item changes.
public IReadOnlyList<object?> Selection { get; } #The selected values of a selection item, in list order.
public object? SelectedValue { get; } #The selected value of a single-selection item, or null.