Choice
ConsoleMonster.Interactive
One option in a selection prompt, menu or choice field: the value returned when it is chosen, the title shown, and optional group, description, hotkey, badge, disabled reason and initial selection.
Inheritance
- object
- Choice
Usage
Explore 86 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 31
- Extension method Choice.Badge
- Extension method Choice.Description
- Extension method Choice.DisabledReason
- Extension method Choice.Group
- Extension method Choice.Hotkey
- Extension method Choice.Label
- Extension method Choice.Preview
- Extension method Choice.RichTitle
- Extension method Choice.Selected
- Extension method Choice.Tag
- Method Choice.From``1
- Property ChoiceField.Choices
- Property ChoiceField.LoadChoices
- Property ChoiceField.Preview
- Method ChoiceFluent.Badge
- Method ChoiceFluent.Description
- Method ChoiceFluent.DisabledReason
- Method ChoiceFluent.Group
- Method ChoiceFluent.Hotkey
- Method ChoiceFluent.Label
- Method ChoiceFluent.Preview
- Method ChoiceFluent.RichTitle
- Method ChoiceFluent.Selected
- Method ChoiceFluent.Tag
- Property MenuItem.Choices
- Property MenuItem.LoadChoices
- Property MenuItem.Preview
- Property MultiSelectPrompt<T>.Choices
- Property SelectInputOptions.Choices
- Property SelectPrompt<T>.Choices
- Property SelectQuestionOptions.Choices
Accepted by parameters 55
- Extension method Choice.Badge
- Extension method Choice.Description
- Extension method Choice.DisabledReason
- Extension method Choice.Group
- Extension method Choice.Hotkey
- Extension method Choice.Label
- Extension method Choice.Preview
- Extension method Choice.RichTitle
- Extension method Choice.Selected
- Extension method Choice.Tag
- Extension method ChoiceField.Choice
- Extension method ChoiceField.Choices
- Extension method ChoiceField.ChoicesBy
- Extension method ChoiceField.PreviewBy
- Method ChoiceFieldFluent.Choice
- Method ChoiceFieldFluent.Choices
- Method ChoiceFieldFluent.ChoicesBy
- Method ChoiceFieldFluent.PreviewBy
- Method ChoiceFluent.Badge
- Method ChoiceFluent.Description
- Method ChoiceFluent.DisabledReason
- Method ChoiceFluent.Group
- Method ChoiceFluent.Hotkey
- Method ChoiceFluent.Label
- Method ChoiceFluent.Preview
- Method ChoiceFluent.RichTitle
- Method ChoiceFluent.Selected
- Method ChoiceFluent.Tag
- Method Form.MultiSelect
- Method Form.Select
- Method FormPage.MultiSelect
- Method FormPage.Select
- Extension method MenuItem.Choice
- Extension method MenuItem.Choices
- Extension method MenuItem.ChoicesBy
- Extension method MenuItem.PreviewBy
- Method MenuItemFluent.Choice
- Method MenuItemFluent.Choices
- Method MenuItemFluent.ChoicesBy
- Method MenuItemFluent.PreviewBy
- Method MultiSelectPromptFluent.Choices``1
- Method MultiSelectPromptFluent.Choice``1
- Constructor MultiSelectPrompt<T>.MultiSelectPrompt
- Constructor Select.Select
- Extension method SelectInputOptions.Choice
- Extension method SelectInputOptions.Choices
- Method SelectInputOptionsFluent.Choice
- Method SelectInputOptionsFluent.Choices
- Method SelectPromptFluent.Choices``1
- Method SelectPromptFluent.Choice``1
- Constructor SelectPrompt<T>.SelectPrompt
- Extension method SelectQuestionOptions.Choice
- Extension method SelectQuestionOptions.Choices
- Method SelectQuestionOptionsFluent.Choice
- Method SelectQuestionOptionsFluent.Choices
Constructors
public Choice(object? value, string? label = null) #Creates a choice.
Parameters
- value object?
- The value returned when chosen (any object).
- label string? = null
- The title shown; null uses the value's text.
Methods
public static List<Choice> From<T>(IEnumerable<T?> choices, Func<T?, string>? display = null, Func<T?, string?>? groupBy = null, Func<T?, string?>? describe = null, Func<T?, RichText?>? badge = null, Func<T?, string?>? disabledReason = null) #Builds choices from values using the shared display and metadata selectors.
Type Parameters
- T
- The value type.
Parameters
- choices System.Collections.Generic.IEnumerable<T?>
- The choices.
- display System.Func<T?, string>? = null
- The label for a value; null uses its text.
- groupBy System.Func<T?, string?>? = null
- The group heading for a value, or null.
- describe System.Func<T?, string?>? = null
- Help text for a value, or null.
- badge System.Func<T?, ConsoleMonster.Text.RichText?>? = null
- A styled badge for a value, or null.
- disabledReason System.Func<T?, string?>? = null
- Why a value cannot be selected; null or empty keeps it enabled.
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 RichText? RichTitle { get; set; } #A styled title shown instead of Choice.Label while no filter is active.
public string? Description { get; set; } #A sentence shown under the list while the choice has focus.
public char? Hotkey { get; set; } #A key that picks the choice directly (letters and digits).
public RichText? Badge { get; set; } #Short right-aligned text: a count, a state, a tag ("new", "24 tasks").
public string? DisabledReason { get; set; } #Why the choice cannot be picked; null when it can. Disabled choices are dimmed and show the reason on focus.
public bool Selected { get; set; } #Whether a multi-selection starts with this choice selected.
public IWidget? Preview { get; set; } #Content for the preview pane while the choice has focus (overrides the prompt's preview function).
Extension Methods
public static Choice Badge(Choice choice, RichText? value) #Sets Choice.Badge: Short right-aligned text: a count, a state, a tag ("new", "24 tasks").
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- value ConsoleMonster.Text.RichText?
- The value.
Examples
// C# initializer or property // C# fluent
choice.Badge = value; choice.Badge(value);public static Choice Badge(Choice choice, Action<RichText> configure) #Configures Choice.Badge in place: Short right-aligned text: a count, a state, a tag ("new", "24 tasks").
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- configure System.Action<ConsoleMonster.Text.RichText>
- Configures the value.
public static Choice Description(Choice choice, string? value) #Sets Choice.Description: A sentence shown under the list while the choice has focus.
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
choice.Description = value; choice.Description(value);public static Choice DisabledReason(Choice choice, string? value) #Sets Choice.DisabledReason: Why the choice cannot be picked; null when it can. Disabled choices are dimmed and show the reason on focus.
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
choice.DisabledReason = value; choice.DisabledReason(value);public static Choice Group(Choice choice, string? value) #Sets Choice.Group: The group heading the choice is listed under.
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
choice.Group = value; choice.Group(value);public static Choice Hotkey(Choice choice, char? value) #Sets Choice.Hotkey: A key that picks the choice directly (letters and digits).
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- value char?
- The value.
Examples
// C# initializer or property // C# fluent
choice.Hotkey = value; choice.Hotkey(value);public static Choice Label(Choice choice, string value) #Sets Choice.Label: The title, also what the filter matches.
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- value string
- The value.
Examples
// C# initializer or property // C# fluent
choice.Label = value; choice.Label(value);public static Choice Preview(Choice choice, IWidget? value) #Sets Choice.Preview: Content for the preview pane while the choice has focus (overrides the prompt's preview function).
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- value ConsoleMonster.Layout.IWidget?
- The value.
Examples
// C# initializer or property // C# fluent
choice.Preview = value; choice.Preview(value);public static Choice RichTitle(Choice choice, RichText? value) #Sets Choice.RichTitle: A styled title shown instead of Choice.Label while no filter is active.
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- value ConsoleMonster.Text.RichText?
- The value.
Examples
// C# initializer or property // C# fluent
choice.RichTitle = value; choice.RichTitle(value);public static Choice RichTitle(Choice choice, Action<RichText> configure) #Configures Choice.RichTitle in place: A styled title shown instead of Choice.Label while no filter is active.
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- configure System.Action<ConsoleMonster.Text.RichText>
- Configures the value.
public static Choice Selected(Choice choice, bool value = true) #Sets Choice.Selected: Whether a multi-selection starts with this choice selected.
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
choice.Selected = value; choice.Selected(value);public static Choice Tag(Choice choice, object? value) #Sets Choice.Tag: Any extra object for the caller.
Parameters
- choice ConsoleMonster.Interactive.Choice
- The instance.
- value object?
- The value.
Examples
// C# initializer or property // C# fluent
choice.Tag = value; choice.Tag(value);