Choice items
A ChoiceItem (in UIToolbox) is one choice: Text, Detail, Icon, Group, Enabled, Locked (shown with its reason in Detail but not picked; a locked item is not Enabled), Explored (a choice the player has already used; it shows dimmed and can still be picked), Tone (the color and glyph of a choice in a ChoiceWheel, and the color of its number in a ChoiceMenu), InsertText (for an AutoCompleteField) and Keywords (more words that a SearchDropdown matches but does not show). A string converts to a ChoiceItem with only the text. The same list of items can fill a SearchDropdown and a context menu:


var commands = new List<ChoiceItem>
{
new("New", "Ctrl+N", group: "File"),
new("Print", "Ctrl+P", group: "File", enabled: false),
new("Undo", "Ctrl+Z", group: "Edit")
};
search.Items = commands;
var menu = new ContextMenuComponent();
menu.AddItems(commands, item => run(item.Text));
ContextMenuComponent.AddItems(items, picked)adds aMenuItemfor each item. The detail is the shortcut text on the right. The icon and the enabled state carry over. A separator goes between two groups.pickedgets theChoiceItemthat runs.ChoiceListis the popup list ofSearchDropdown,ComboBoxandAutoCompleteField: anAnchoredPopupwith aListViewof group headers and items. A new control that suggests choices can use it.SetItemsshows the items,MoveHighlightandPickHighlightedare the Up, Down and Enter keys, andPickedandClosedreport back.IsSelected,Query,MakeItemandBindItemwork as they do onSearchDropdown.- ChoiceMenu shows the items as numbered buttons in the layout, with the same row parts as
ChoiceList, such as the answers of a DialogueBox. - ChoiceWheel shows the items around a ring, such as a dialogue wheel.
Tone(Neutral,Friendly,Investigate,Hostile,DeceiveorLeave) gives the wedge of a choice its color and glyph; aChoiceMenucolors the number of the choice, and the other controls do not show it.
SVG: ChoiceItem.VectorIcon is the SVG beside Icon and shows in place of it. A MenuItem has VectorIcon too, and AddItems copies it. An SVG imported as a VectorImage works as well as a texture. See Pictures: PNG or SVG.
This is a helper, not a control. A ChoiceItem is data: the controls that show choices take a list of them.