Class Dropdown
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
anchorAnchorThe dropdown's anchor
sizeVector2The dropdown button's size
textCallbackParagraph.TextCallbackThe text displayed on the dropdown button
tooltipTextCallbackParagraph.TextCallbackThe text displayed as a tooltip when hovering over the dropdown button
panelHeightfloatThe height of the Panel. If this is 0, the panel will be set to SetHeightBasedOnChildren.
scrollPanelboolWhether this dropdown's Panel should automatically add a scroll bar to scroll towards elements that are beyond the area it covers.
autoHidePanelScrollbarboolWhether 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
scrollPanelis 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
anchorAnchorThe dropdown's anchor
sizeVector2The dropdown button's size
panelHeightfloatThe height of the Panel. If this is 0, the panel will be set to SetHeightBasedOnChildren.
scrollPanelboolWhether this dropdown's Panel should automatically add a scroll bar to scroll towards elements that are beyond the area it covers.
autoHidePanelScrollbarboolWhether 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
scrollPanelis 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
anchorAnchorThe dropdown's anchor
sizeVector2The dropdown button's size
textstringThe text displayed on the dropdown button
tooltipTextstringThe text displayed as a tooltip when hovering over the dropdown button
panelHeightfloatThe height of the Panel. If this is 0, the panel will be set to SetHeightBasedOnChildren.
scrollPanelboolWhether this dropdown's Panel should automatically add a scroll bar to scroll towards elements that are beyond the area it covers.
autoHidePanelScrollbarboolWhether 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
scrollPanelis 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
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
ArrowPadding
public StyleProp<Padding> ArrowPadding { get; set; }
Property Value
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
IsOpen
This property stores whether the dropdown is currently opened or not
public bool IsOpen { get; set; }
Property Value
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
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
Methods
AddElement(Element, int)
Adds an element to this dropdown's Panel
public Element AddElement(Element element, int index = -1)
Parameters
elementElementThe element to add
indexintThe index to add the child at, or -1 to add it to the end of the Children list
Returns
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
textParagraph.TextCallbackThe text to display
pressedElement.GenericCallbackThe resulting paragraph's OnPressed event
indexintThe index to add the child at, or -1 to add it to the end of the Children list
Returns
AddElement(string, GenericCallback, int)
public Paragraph AddElement(string text, Element.GenericCallback pressed = null, int index = -1)
Parameters
textstringThe text to display
pressedElement.GenericCallbackThe resulting paragraph's OnPressed event
indexintThe index to add the child at, or -1 to add it to the end of the Children list
Returns
InitStyle(UiStyle)
Initializes this element's StyleProp<T> instances using the ui system's UiStyle.
protected override void InitStyle(UiStyle style)
Parameters
styleUiStyleThe new style