Skip to content

Selection

Justin Oroz edited this page Jul 7, 2017 · 14 revisions

Dropdown

Overview

Adding a ModOptionSelection object to your menu displays a Dropdown which expands to a list of items when clicked which can be selected.

Usage

Initializing

ModOptionSelection myDropdown = new ModOptionSelection("mySetting", "Option Label");

ModOptionSelection 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 ModOptions.

The choices argument is of type ModSelectionOptionChoices which has its own section at the end of this document. If it is left as default an empty ModSelectionOptionChoices will be assigned to ModOptionSelection.Choices to which choices can be added. If you prefer to set up the choices before initializing the ModOptionSelection it can be created, added to, then passed into the initializer.

The defaultSelection argument allows for the selection of a choice at initialization. The index must be in the range of the choices argument.

Reading/Modifying Values

To read which dropdown value is selected check the string Selection which returns the identifier or int SelectionIndex property. The event ValueChanged is triggered every time the selection is changed through either Selection or SelectionIndex properties, except on initialization.

The mod can manually change the state of the checkbox 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.

Properties and Methods

Initializers

public ModOptionSelection(string identifier, string labelText,  ModSelectionOptionChoices choices = null, int defaultSelection = 0, bool enabled = true);

Properties

public ModSelectionOptionChoices Choices { get; }
public int SelectionIndex { get; set; }
public string Selection { get; set; }

Events

public delegate void ModOptionSelectionHandler(string ComponentIdentifier, string selectionIdentifier);
public event ModOptionSelectionHandler ValueChanged;

ModSelectionOptionChoices

Methods

public new string this[int key];
public string this[string identifier];
public void Insert(int index, string identifier, string label);
public void Add(string identifier, string label);
public void Remove(string identifier);
public bool Contains(string identifier);
public int IndexOf(string identifier);
public string IdentifierOf(int index);
public string LabelOf(int index);
public string LabelOf(string identifier);
public int IndexOfLabel(string label);
public string IdentifierOfLabel(string label);

Properties

public List<string> Identifiers { get; }
public List<string> Labels { get; }
Clone this wiki locally