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. Elements can be added to the dropdown's Panel through AddElement(Element, int) or one of its overloads, which additionally causes them to have correct gamepad navigation behavior.

public class Dropdown : Button, IGenericDataHolder, ILayoutItem
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

HoveredTextColor

A style property containing the Microsoft.Xna.Framework.Color that a paragraph added to this dropdown through AddElement(TextCallback, GenericCallback, int) should have when hovered. For elements added through other overloads of AddElement(Element, int), this property has no effect.

public StyleProp<Color> HoveredTextColor

Field Value

StyleProp<Color>

OnOpenedOrClosed

An event that is invoked when IsOpen changes

public Element.GenericCallback OnOpenedOrClosed

Field Value

Element.GenericCallback

TextColor

A style property containing the Microsoft.Xna.Framework.Color that a paragraph added to this dropdown through AddElement(TextCallback, GenericCallback, int) should have by default. For elements added through other overloads of AddElement(Element, int), this property has no effect.

public StyleProp<Color> TextColor

Field Value

StyleProp<Color>

Properties

Arrow

The Image that contains the currently active arrow texture for this dropdown, which is either ClosedArrowTexture or OpenedArrowTexture.

public Image Arrow { get; }

Property Value

Image

ArrowPadding

A style property containing the Padding that should be passed to the Arrow child element.

public StyleProp<Padding> ArrowPadding { get; set; }

Property Value

StyleProp<Padding>

ClosedArrowTexture

A style property containing the TextureRegion that should be displayed on this dropdown's Arrow when the dropdown is closed (IsOpen is false).

public StyleProp<TextureRegion> ClosedArrowTexture { get; set; }

Property Value

StyleProp<TextureRegion>

IsOpen

This property stores whether the dropdown is currently opened or not

public bool IsOpen { get; set; }

Property Value

bool

OpenedArrowTexture

A style property containing the TextureRegion that should be displayed on this dropdown's Arrow when the dropdown is open (IsOpen is true).

public StyleProp<TextureRegion> OpenedArrowTexture { get; set; }

Property Value

StyleProp<TextureRegion>

Panel

The panel that this dropdown contains. It will be displayed upon pressing the dropdown button. To add elements to this panel, you can use AddElement(Element, int) or one of its overloads, which additionally causes them to have correct gamepad navigation behavior.

public Panel Panel { get; }

Property Value

Panel

Methods

AddElement(Element, int)

Adds an element to this dropdown's Panel

public Element 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

Returns

Element

AddElement(TextCallback, GenericCallback, int)

Adds a pressable Paragraph element to this dropdown's Panel. By default, the paragraph's text color will change from TextColor to HoveredTextColor when hovering over it.

public Paragraph 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

Paragraph

AddElement(string, GenericCallback, int)

Adds a pressable Paragraph element to this dropdown's Panel

public Paragraph 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

Paragraph

InitStyle(UiStyle)

Initializes this element's StyleProp<T> instances using the ui system's UiStyle.

protected override void InitStyle(UiStyle style)

Parameters

style UiStyle

The new style