Skip to main content

Dropdown

See the DropdownDemo class.

public void Draw()
{
Gui.Heading("Dropdown");
// Pass the selected enum as the argument.
Gui.Dropdown(ref sampleEnum1);
Gui.Dropdown(items1, ref selectedIndex1);

// Multiple selections possible
Gui.Dropdown(ref sampleFlagEnum);

Gui.Heading("LabelDropdown");
Gui.LabelDropdown("with label", items1, ref selectedIndex1);
Gui.LabelDropdown("with label", ref sampleEnum2);

Gui.Heading("InputDropdown");
Gui.InputDropdown(items1, ref selectedIndex1);
Gui.InputDropdown(ref sampleEnum2);

// The items will be scrolled because their total height is greater than MaxHeights.
using (Style.Dropdown.MaxHeights.Begin(100))
Gui.InputDropdown(items2, ref selectedIndex2);
}

enum SampleEnum
{
Element0,
Element1,
Element2
}

// If FlagsAttribute is attached, multiple selection is possible.
[Flags]
enum SampleFlagEnum
{
Element0 = 0,
Element1 = 1 << 0,
Element2 = 1 << 1,
Element3 = 1 << 2,
Element4 = 1 << 3,
}