UI Toolbox logoUI Toolbox
Support

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:

A Command dropdown open on ChoiceItem entries grouped under File and Edit with keyboard shortcuts and a disabled Print map itemA Command dropdown open on ChoiceItem entries grouped under File and Edit with keyboard shortcuts and a disabled Print map item

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));

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.