Class Dropdown
Dropdown menu control allows to choose one item from the provided collection of options.
Implements
Namespace: FlaxEngine.GUI
Assembly: FlaxEngine.CSharp.dll
Syntax
[ActorToolbox("GUI")]
public class Dropdown : ContainerControl, IComparable, IDrawable
Constructors
Dropdown()
Fields
_items
The items.
Declaration
protected List<LocalizedString> _items
Field Value
|
System.Collections.Generic.List<LocalizedString>
|
_popup
The popup menu. May be null if has not been used yet.
Declaration
protected Dropdown.DropdownRoot _popup
Field Value
|
FlaxEngine.GUI.Dropdown.DropdownRoot
|
_selectedIndex
The selected index of the item (-1 for no selection).
Declaration
protected int _selectedIndex
Field Value
|
System.Int32
|
Properties
ArrowColor
Gets or sets the color used to render dropdown drop arrow icon.
Declaration
[EditorDisplay("Icon Style", null)]
[EditorOrder(2030)]
[Tooltip("The color used to render dropdown drop arrow icon.")]
[ExpandGroups]
public Color ArrowColor { get; set; }
Property Value
|
Color
|
ArrowColorHighlighted
Gets or sets the color used to render dropdown drop arrow icon (menu is highlighted).
Declaration
[EditorDisplay("Icon Style", null)]
[EditorOrder(2031)]
[Tooltip("The color used to render dropdown drop arrow icon (menu is highlighted).")]
public Color ArrowColorHighlighted { get; set; }
Property Value
|
Color
|
ArrowColorSelected
Gets or sets the color used to render dropdown drop arrow icon (menu is opened).
Declaration
[EditorDisplay("Icon Style", null)]
[EditorOrder(2032)]
[Tooltip("The color used to render dropdown drop arrow icon (menu is opened).")]
public Color ArrowColorSelected { get; set; }
Property Value
|
Color
|
ArrowImage
Gets or sets the image used to render dropdown drop arrow icon.
Declaration
[EditorDisplay("Icon Style", null)]
[EditorOrder(2033)]
[Tooltip("The image used to render dropdown drop arrow icon.")]
public IBrush ArrowImage { get; set; }
Property Value
|
IBrush
|
BackgroundColorHighlighted
Gets or sets the background color when dropdown is highlighted.
Declaration
[EditorDisplay("Background Style", null)]
[EditorOrder(2001)]
[ExpandGroups]
public Color BackgroundColorHighlighted { get; set; }
Property Value
|
Color
|
BackgroundColorSelected
Gets or sets the background color when dropdown popup is opened.
Declaration
[EditorDisplay("Background Style", null)]
[EditorOrder(2002)]
public Color BackgroundColorSelected { get; set; }
Property Value
|
Color
|
BorderColor
Gets or sets the color of the border.
Declaration
[EditorDisplay("Border Style", null)]
[EditorOrder(2010)]
[ExpandGroups]
public Color BorderColor { get; set; }
Property Value
|
Color
|
BorderColorHighlighted
Gets or sets the border color when dropdown is highlighted.
Declaration
[EditorDisplay("Border Style", null)]
[EditorOrder(2013)]
public Color BorderColorHighlighted { get; set; }
Property Value
|
Color
|
BorderColorSelected
Gets or sets the border color when dropdown popup is opened.
Declaration
[EditorDisplay("Border Style", null)]
[EditorOrder(2012)]
public Color BorderColorSelected { get; set; }
Property Value
|
Color
|
CheckedImage
Gets or sets the image used to render dropdown checked item icon.
Declaration
[EditorDisplay("Icon Style", null)]
[EditorOrder(2034)]
[Tooltip("The image used to render dropdown checked item icon.")]
public IBrush CheckedImage { get; set; }
Property Value
|
IBrush
|
Font
Gets or sets the font used to draw text.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2020)]
public FontReference Font { get; set; }
Property Value
|
FontReference
|
FontMaterial
Gets or sets the custom material used to render the text. It must has domain set to GUI and have a public texture parameter named Font used to sample font atlas texture with font characters data.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2021)]
public MaterialBase FontMaterial { get; set; }
Property Value
|
MaterialBase
|
HorizontalAlignment
Gets or sets the horizontal text alignment within the control bounds.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2027)]
public TextAlignment HorizontalAlignment { get; set; }
Property Value
|
TextAlignment
|
IsPopupOpened
Gets a value indicating whether this popup menu is opened.
Declaration
public bool IsPopupOpened { get; }
Property Value
|
System.Boolean
|
Items
Gets or sets the items collection.
Declaration
[EditorOrder(1)]
public List<LocalizedString> Items { get; set; }
Property Value
|
System.Collections.Generic.List<LocalizedString>
|
SelectedIndex
Gets or sets the index of the selected.
Declaration
[EditorOrder(2)]
[Limit(-1F, 3.40282347E+38F, 1F)]
[Tooltip("The index of the selected item from the list.")]
public int SelectedIndex { get; set; }
Property Value
|
System.Int32
|
ShowAllItems
Gets or sets whether to show all the items in the dropdown.
Declaration
[EditorOrder(3)]
public bool ShowAllItems { get; set; }
Property Value
|
System.Boolean
|
ShowMaxItemsCount
Gets or sets the maximum number of items to show at once. Only used if ShowAllItems is false.
Declaration
[EditorOrder(4)]
[VisibleIf("ShowAllItems", true)]
[Limit(1F, 3.40282347E+38F, 1F)]
public int ShowMaxItemsCount { get; set; }
Property Value
|
System.Int32
|
TextColor
Gets or sets the color of the text.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2023)]
[ExpandGroups]
public Color TextColor { get; set; }
Property Value
|
Color
|
TextFormat
Gets or sets the custom text format for selected item displaying. Can be used to prefix or/and postfix actual selected value within the drowpdown control text where '{0}' is used to insert selected value text. Example: 'Selected: {0}'. Leave empty if unussed.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2022)]
public LocalizedString TextFormat { get; set; }
Property Value
|
LocalizedString
|
VerticalAlignment
Gets or sets the vertical text alignment within the control bounds.
Declaration
[EditorDisplay("Text Style", null)]
[EditorOrder(2028)]
public TextAlignment VerticalAlignment { get; set; }
Property Value
|
TextAlignment
|
Methods
AddItem(String)
Adds the item.
Declaration
public void AddItem(string item)
Parameters
|
System.String
item
The item. |
AddItems(IEnumerable<String>)
Adds the items.
Declaration
public void AddItems(IEnumerable<string> items)
Parameters
|
System.Collections.Generic.IEnumerable<System.String>
items
The items. |
ClearItems()
Clears the items.
Declaration
public void ClearItems()
CreatePopup()
Creates the popup menu (including items collection).
Declaration
protected virtual Dropdown.DropdownRoot CreatePopup()
Returns
|
FlaxEngine.GUI.Dropdown.DropdownRoot
|
CreatePopupBackground(Dropdown.DropdownRoot)
Creates the popup background. Called by default implementation of CreatePopup() and allows to customize popup background by adding controls to it.
Declaration
protected virtual void CreatePopupBackground(Dropdown.DropdownRoot popup)
Parameters
|
FlaxEngine.GUI.Dropdown.DropdownRoot
popup
The popup control where background controls can be added. |
CreatePopupItem(Int32, Float2, Single)
Creates the popup item. Called by default implementation of CreatePopup() and allows to customize popup item.
Declaration
protected virtual Control CreatePopupItem(int i, Float2 size, float margin)
Parameters
|
System.Int32
i
The item index. |
|
Float2
size
The item control size |
|
System.Single
margin
The item control left-side margin |
Returns
|
Control
Custom popup item control. |
CreatePopupRoot()
Creates the popup root. Called by default implementation of CreatePopup() and allows to customize popup base.
Declaration
protected virtual Dropdown.DropdownRoot CreatePopupRoot()
Returns
|
FlaxEngine.GUI.Dropdown.DropdownRoot
Custom popup root control. |
DestroyPopup()
Destroys the popup.
Declaration
protected virtual void DestroyPopup()
DrawSelf()
Draws the control.
Declaration
public override void DrawSelf()
Overrides
HidePopup()
Hides the popup.
Declaration
public void HidePopup()
OnDestroy()
Method called when managed instance should be destroyed
Declaration
public override void OnDestroy()
Overrides
OnItemClicked(Int32)
Called when item is clicked.
Declaration
protected virtual void OnItemClicked(int index)
Parameters
|
System.Int32
index
The index. |
OnLostFocus()
When control losts input focus
Declaration
public override void OnLostFocus()
Overrides
OnMouseDoubleClick(Float2, MouseButton)
When mouse double clicks over control's area
Declaration
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
Parameters
|
Float2
location
Mouse location in Control Space |
|
MouseButton
button
Mouse buttons state (flags) |
Returns
|
System.Boolean
True if event has been handled, otherwise false |
Overrides
OnMouseDown(Float2, MouseButton)
When mouse goes down over control's area
Declaration
public override bool OnMouseDown(Float2 location, MouseButton button)
Parameters
|
Float2
location
Mouse location in Control Space |
|
MouseButton
button
Mouse buttons state (flags) |
Returns
|
System.Boolean
True if event has been handled, otherwise false |
Overrides
OnMouseLeave()
When mouse leaves control's area
Declaration
public override void OnMouseLeave()
Overrides
OnMouseUp(Float2, MouseButton)
When mouse goes up over control's area
Declaration
public override bool OnMouseUp(Float2 location, MouseButton button)
Parameters
|
Float2
location
Mouse location in Control Space |
|
MouseButton
button
Mouse buttons state (flags) |
Returns
|
System.Boolean
True if event has been handled, otherwise false |
Overrides
OnPopupHide()
Called when popup menu gets hidden.
Declaration
protected virtual void OnPopupHide()
OnPopupShow()
Called when popup menu gets shown.
Declaration
protected virtual void OnPopupShow()
OnSelectedIndexChanged()
Called when selected item index gets changed.
Declaration
protected virtual void OnSelectedIndexChanged()
OnSubmit()
Generic user interaction event for a control used by UI navigation (eg. user submits on the currently focused control).
Declaration
public override void OnSubmit()
Overrides
OnTouchDown(Float2, Int32)
When touch enters control's area.
Declaration
public override bool OnTouchDown(Float2 location, int pointerId)
Parameters
|
Float2
location
Touch location in Control Space. |
|
System.Int32
pointerId
The touch pointer identifier. Stable for the whole touch gesture/interaction. |
Returns
|
System.Boolean
True if event has been handled, otherwise false. |
Overrides
OnTouchLeave(Int32)
When touch leaves control's area
Declaration
public override void OnTouchLeave(int pointerId)
Parameters
|
System.Int32
pointerId
The touch pointer identifier. Stable for the whole touch gesture/interaction. |
Overrides
OnTouchUp(Float2, Int32)
When touch goes up over control's area.
Declaration
public override bool OnTouchUp(Float2 location, int pointerId)
Parameters
|
Float2
location
Touch location in Control Space |
|
System.Int32
pointerId
The touch pointer identifier. Stable for the whole touch gesture/interaction. |
Returns
|
System.Boolean
True if event has been handled, otherwise false. |
Overrides
SetItems(IEnumerable<String>)
Sets the items.
Declaration
public void SetItems(IEnumerable<string> items)
Parameters
|
System.Collections.Generic.IEnumerable<System.String>
items
The items. |
ShowPopup()
Shows the popup.
Declaration
public void ShowPopup()
Events
SelectedIndexChanged
Event fired when selected index gets changed.
Declaration
public event Action<Dropdown> SelectedIndexChanged
Event Type
|
System.Action<Dropdown>
|
SelectedItemChanged
Event fired when selected item gets changed.
Declaration
public event Action SelectedItemChanged
Event Type
|
System.Action
|