Skip to content
ConsoleMonster

API Reference

Class

Choice

Namespace ConsoleMonster.Interactive
Assembly ConsoleMonster
Modifiers sealed

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 16 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.

Accepted by parameters 7

Constructors

public Choice(Object? value, String? title = null) #

Creates a choice.

Parameters

value System.Object? requiredposition: 0
The value returned when chosen (any object).
title System.String? = null optionalposition: 1
The title shown; null uses the value's text.

Methods

public static List<Choice> From<T>(IEnumerable<T?> values, Func<T?, String>? title = null, Func<T?, String?>? group = null) #
Returns: List<Choice>

Builds choices from values with a title selector.

Type Parameters

T
The value type.

Parameters

values System.Collections.Generic.IEnumerable<T?> requiredposition: 0
The values.
title System.Func<T?, System.String>? = null optionalposition: 1
The title for a value; null uses its text.
group System.Func<T?, System.String?>? = null optionalposition: 2
The group for a value, or null.

Returns

The choices.

public override String ToString() #
Returns: String

Returns a string that represents the current object.

Returns

A string that represents the current object.

Properties

public Object? Value { get; } #

The value returned when chosen.

public String Title { get; set; } #

The title, also what the filter matches.

public RichText? RichTitle { get; set; } #

A styled title shown instead of Choice.Title while no filter is active.

public String? Description { get; set; } #

A sentence shown under the list while the choice has focus.

public String? Group { get; set; } #

The group heading the choice is listed under.

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 Boolean 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).

public Object? Tag { get; set; } #

Any extra object for the caller.

public Boolean IsEnabled { get; } #

Whether the choice can be picked.