-
Notifications
You must be signed in to change notification settings - Fork 1
Selection
Adding a ConfigSelection
object to your menu displays a Dropdown which expands to a list of items when clicked which can be selected.
ConfigSelection myDropdown = new ConfigSelection("mySetting", "Option Label");
ConfigSelection
initialization requires only an identifier
, label
but can be initialized with additional arguments choices
, defaultSelection
and the standard enabled
. You will then want to add options using its methods, and can then add it to an OptionsTab
.
The choices
argument accepts an IList<ISelectionChoice>
. If it is left as default Choices
will be empty but can be accessed to add SelectionChoice
. When loading from previous data it's good practice to supply the choice list at initialization.
The defaultSelection
argument allows for the selection of a choice at initialization. The index must be in the range of the choices argument.
To read which dropdown value is selected check SelectedIdentifier
or SelectionIndex
property. The event ValueChanged
is triggered every time the selection is changed through either SelectedIdentifier
or SelectionIndex
properties, except on initialization.
The mod can manually change the state of the dropdown by writing to the Selection
or SelectionIndex
properties. If the identifier string does exist the list or the index is out of range an exception will be thrown.
To execute code when the selection changes subscribe to the SelectionDidChange
event.
A SelectionChoice
object contains the data for each choice in the ConfigSelection
. This data includes an identifier
, label
and optional hoverText
.
SelectionChoice(string identifier, string label, string hoverText = null)
ConfigSelection(string identifier, string labelText, IList<ISelectionChoice> choices = null, int defaultSelection = 0, bool enabled = true)
ConfigSelection(string identifier, string labelText, IList<ISelectionChoice> choices, string defaultSelection, bool enabled = true);
IOrderedDictionary<ISelectionChoice> Choices { get; }
ISelectionChoice SelectedChoice { get; }
public int SelectedIndex { get; set; }
public string SelectedIdentifier { get; set; }
string Identifier { get; }
string Label { get; set; }
event SelectionHandler SelectionDidChange;