Class Dropdown<T>
- Namespace
- UILib.Components
- Assembly
- UILib.dll
A component which displays a dropdown of multiple options.
IMPORTANT: Don't rely on the API staying this way, dropdowns are not implemented all that well at the moment and so are subject to change.
public class Dropdown<T> : UIComponent
Type Parameters
T
- Inheritance
-
Dropdown<T>
- Inherited Members
Constructors
Dropdown(T, int, string)
Initializes a dropdown with a specified default value.
If defaultDisplayName is null, the ToString method of
the default option will be used instead.
public Dropdown(T defaultValue, int fontSize, string defaultDisplayName = null)
Parameters
defaultValueTThe default value to display
fontSizeintThe font size to use in this dropdown
defaultDisplayNamestringThe display name of the default value to show
Properties
onValueChanged
An event which invokes listeners whenever a new value is selected by the user. Passes the value which was selected.
public ValueEvent<T> onValueChanged { get; }
Property Value
- ValueEvent<T>
value
The current value of the dropdown.
public T value { get; }
Property Value
- T
Methods
AddOption(T, string)
Adds an option to this dropdown.
If displayName is null, the option's
ToString method will be called instead.
public void AddOption(T option, string displayName = null)
Parameters
optionTThe option to add
displayNamestringA custom display name
AddOptions(Dictionary<string, T>)
Adds many options to this dropdown.
The string key indicates the display names
these options should have.
public void AddOptions(Dictionary<string, T> options)
Parameters
optionsDictionary<string, T>The options to add
AddOptions(IList<T>)
Adds many options to this dropdown.
public void AddOptions(IList<T> options)
Parameters
optionsIList<T>The options to add
SetOption(T, string)
Sets the current option of the dropdown.
If displayName is null, the option's
ToString method will be called instead.
public void SetOption(T option, string displayName = null)
Parameters
optionTThe option to set
displayNamestringThe display name of this option
SetOptionCount(int)
Set how many options you want to display in the dropdown (without needing to scroll).
public void SetOptionCount(int optionCount)
Parameters
optionCountintThe number of options to display
SetSize(float, float)
Sets the size of this dropdown. This also sets the size of all child options.
public override void SetSize(float width, float height)
Parameters
SetThisTheme(Theme)
Allows setting the theme of this dropdown. Does nothing.
This handles setting the theme specifically for this component, not its children. It's protected to allow overriding if you were to create a subclass.
In most cases, you'd probably want to use SetTheme(Theme) instead.
protected override void SetThisTheme(Theme theme)
Parameters
themeThemeThe theme to apply