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.
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
AnchorThe dropdown's anchor
size
Vector2The dropdown button's size
textCallback
Paragraph.TextCallbackThe text displayed on the dropdown button
tooltipTextCallback
Paragraph.TextCallbackThe text displayed as a tooltip when hovering over the dropdown button
panelHeight
floatThe height of the Panel. If this is 0, the panel will be set to SetHeightBasedOnChildren.
scrollPanel
boolWhether this dropdown's Panel should automatically add a scroll bar to scroll towards elements that are beyond the area it covers.
autoHidePanelScrollbar
boolWhether 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
AnchorThe dropdown's anchor
size
Vector2The dropdown button's size
panelHeight
floatThe height of the Panel. If this is 0, the panel will be set to SetHeightBasedOnChildren.
scrollPanel
boolWhether this dropdown's Panel should automatically add a scroll bar to scroll towards elements that are beyond the area it covers.
autoHidePanelScrollbar
boolWhether 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
AnchorThe dropdown's anchor
size
Vector2The dropdown button's size
text
stringThe text displayed on the dropdown button
tooltipText
stringThe text displayed as a tooltip when hovering over the dropdown button
panelHeight
floatThe height of the Panel. If this is 0, the panel will be set to SetHeightBasedOnChildren.
scrollPanel
boolWhether this dropdown's Panel should automatically add a scroll bar to scroll towards elements that are beyond the area it covers.
autoHidePanelScrollbar
boolWhether 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
Properties
IsOpen
This property stores whether the dropdown is currently opened or not
public bool IsOpen { get; set; }
Property Value
Panel
The panel that this dropdown contains. It will be displayed upon pressing the dropdown button.
public Panel Panel { get; }
Property Value
Methods
AddElement(Element, int)
Adds an element to this dropdown's Panel
public void AddElement(Element element, int index = -1)
Parameters
element
ElementThe element to add
index
intThe 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.TextCallbackThe text to display
pressed
Element.GenericCallbackThe resulting paragraph's OnPressed event
index
intThe index to add the child at, or -1 to add it to the end of the Children list
Returns
AddElement(string, GenericCallback, int)
public Element AddElement(string text, Element.GenericCallback pressed = null, int index = -1)
Parameters
text
stringThe text to display
pressed
Element.GenericCallbackThe resulting paragraph's OnPressed event
index
intThe index to add the child at, or -1 to add it to the end of the Children list