Table of Contents

Class Dropdown

Namespace
MLEM.Ui.Elements
Assembly
MLEM.Ui.dll

A dropdown component to use inside of a UiSystem. A dropdown is a component that contains a hidden panel which is displayed upon pressing the dropdown button.

public class Dropdown : Button, IGenericDataHolder
Inheritance
Dropdown
Implements
Inherited Members
Extension Methods

Constructors

Dropdown(Anchor, Vector2, TextCallback, TextCallback, float, bool, bool)

Creates a new dropdown with the given settings

public Dropdown(Anchor anchor, Vector2 size, Paragraph.TextCallback textCallback = null, Paragraph.TextCallback tooltipTextCallback = null, float panelHeight = 0, bool scrollPanel = false, bool autoHidePanelScrollbar = true)

Parameters

anchor Anchor

The dropdown's anchor

size Vector2

The dropdown button's size

textCallback Paragraph.TextCallback

The text displayed on the dropdown button

tooltipTextCallback Paragraph.TextCallback

The text displayed as a tooltip when hovering over the dropdown button

panelHeight float

The height of the Panel. If this is 0, the panel will be set to SetHeightBasedOnChildren.

scrollPanel bool

Whether this dropdown's Panel should automatically add a scroll bar to scroll towards elements that are beyond the area it covers.

autoHidePanelScrollbar bool

Whether this dropdown's Panel's scroll bar should be hidden automatically if the panel does not contain enough children to allow for scrolling. This only has an effect if scrollPanel is true.

Dropdown(Anchor, Vector2, float, bool, bool)

Creates a new dropdown with the given settings and no text or tooltip.

public Dropdown(Anchor anchor, Vector2 size, float panelHeight = 0, bool scrollPanel = false, bool autoHidePanelScrollbar = true)

Parameters

anchor Anchor

The dropdown's anchor

size Vector2

The dropdown button's size

panelHeight float

The height of the Panel. If this is 0, the panel will be set to SetHeightBasedOnChildren.

scrollPanel bool

Whether this dropdown's Panel should automatically add a scroll bar to scroll towards elements that are beyond the area it covers.

autoHidePanelScrollbar bool

Whether this dropdown's Panel's scroll bar should be hidden automatically if the panel does not contain enough children to allow for scrolling. This only has an effect if scrollPanel is true.

Dropdown(Anchor, Vector2, string, string, float, bool, bool)

Creates a new dropdown with the given settings

public Dropdown(Anchor anchor, Vector2 size, string text = null, string tooltipText = null, float panelHeight = 0, bool scrollPanel = false, bool autoHidePanelScrollbar = true)

Parameters

anchor Anchor

The dropdown's anchor

size Vector2

The dropdown button's size

text string

The text displayed on the dropdown button

tooltipText string

The text displayed as a tooltip when hovering over the dropdown button

panelHeight float

The height of the Panel. If this is 0, the panel will be set to SetHeightBasedOnChildren.

scrollPanel bool

Whether this dropdown's Panel should automatically add a scroll bar to scroll towards elements that are beyond the area it covers.

autoHidePanelScrollbar bool

Whether this dropdown's Panel's scroll bar should be hidden automatically if the panel does not contain enough children to allow for scrolling. This only has an effect if scrollPanel is true.

Fields

OnOpenedOrClosed

An event that is invoked when IsOpen changes

public Element.GenericCallback OnOpenedOrClosed

Field Value

Element.GenericCallback

Properties

IsOpen

This property stores whether the dropdown is currently opened or not

public bool IsOpen { get; set; }

Property Value

bool

Panel

The panel that this dropdown contains. It will be displayed upon pressing the dropdown button.

public Panel Panel { get; }

Property Value

Panel

Methods

AddElement(Element, int)

Adds an element to this dropdown's Panel

public void AddElement(Element element, int index = -1)

Parameters

element Element

The element to add

index int

The index to add the child at, or -1 to add it to the end of the Children list

AddElement(TextCallback, GenericCallback, int)

Adds a pressable Paragraph element to this dropdown's Panel. By default, the paragraph's text color will change from Microsoft.Xna.Framework.Color.White to Microsoft.Xna.Framework.Color.LightGray when hovering over it.

public Element AddElement(Paragraph.TextCallback text, Element.GenericCallback pressed = null, int index = -1)

Parameters

text Paragraph.TextCallback

The text to display

pressed Element.GenericCallback

The resulting paragraph's OnPressed event

index int

The index to add the child at, or -1 to add it to the end of the Children list

Returns

Element

AddElement(string, GenericCallback, int)

Adds a pressable Paragraph element to this dropdown's Panel

public Element AddElement(string text, Element.GenericCallback pressed = null, int index = -1)

Parameters

text string

The text to display

pressed Element.GenericCallback

The resulting paragraph's OnPressed event

index int

The index to add the child at, or -1 to add it to the end of the Children list

Returns

Element