Skip to content

Class DropDownList<T>

Framework View

The tag name of this view is <dropdown>.

Definition

Namespace: StardewUI.Widgets
Assembly: StardewUI.dll

Button/text field with a drop-down menu.

public class DropDownList<T> : StardewUI.Widgets.ComponentView

Type Parameters

T
The type of list item that can be chosen.

Inheritance
ObjectDecoratorView<T>ComponentView<T>ComponentView ⇦ DropDownList<T>

Members

Constructors

Name Description
DropDownList<T>()

Properties

Name Description
ActualBounds
actual-bounds
The bounds of this view relative to the origin (0, 0).
(Inherited from DecoratorView<T>)
ClipOrigin
clip-origin
Origin position for the ClipSize.
(Inherited from DecoratorView<T>)
ClipSize
clip-size
Size of the clipping rectangle, outside which content will not be displayed.
(Inherited from DecoratorView<T>)
ContentBounds
content-bounds
The true bounds of this view's content; i.e. ActualBounds excluding margins.
(Inherited from DecoratorView<T>)
FloatingBounds
floating-bounds
Contains the bounds of all floating elements in this view tree, including the current view and all descendants.
(Inherited from DecoratorView<T>)
HoveredSubject
hovered-subject
When Lookup Anything (Pathoschild.LookupAnything) is loaded, this Object or NPC subject is given to lookup anything for it's menu. (unofficial-mushymato)
(Inherited from DecoratorView<T>)
IsFocusable
is-focusable
Whether or not the view can receive controller focus, i.e. the stick/d-pad controlled cursor can move to this view. Not generally applicable for mouse controls.
(Inherited from DecoratorView<T>)
Layout
layout
The current layout parameters, which determine how Measure(Vector2) will behave.
(Inherited from DecoratorView<T>)
MaxListHeight
max-list-height
Maximum height of the expanded list.
Name
name
Simple name for this view, used in log/debug output; does not affect behavior.
(Inherited from DecoratorView<T>)
Opacity
opacity
Opacity (alpha level) of the view.
(Inherited from DecoratorView<T>)
OptionFormat
option-format
Specifies how to format the SelectedOption in the label text.
OptionMaxLines
option-max-lines
Maximum number of lines to allow per option in the drop-down list.
OptionMinWidth
option-min-width
Minimum width for the text area of an option.
Options
options
The options available to select.
OuterSize
outer-size
The true computed layout size resulting from a single Measure(Vector2) pass.
(Inherited from DecoratorView<T>)
PointerEventsEnabled
pointer-events-enabled
Whether this view should receive pointer events like Click or Drag.
(Inherited from DecoratorView<T>)
PointerStyle
pointer-style
Pointer style to use when this view is hovered.
(Inherited from DecoratorView<T>)
ScreenRead
screen-read
When a screen reader mod (shoaib.stardewaccess) is loaded, this element will be announced by the screen reader using this value. (unofficial-mushymato)
(Inherited from DecoratorView<T>)
ScrollWithChildren
scroll-with-children
If set to an axis, specifies that when any child of the view is scrolled into view (using ScrollIntoView(IEnumerable<ViewChild>, Vector2)), then this entire view should be scrolled along with it.
(Inherited from DecoratorView<T>)
SelectedIndex
selected-index
Index of the currently-selected option in the Options, or -1 if none selected.
SelectedOption
selected-option
The option that is currently selected, or null if there is no selection.
SelectedOptionText
selected-option-text
The text of the currently-selected option.
SelectionFrameLayout
selection-frame-layout
Customizes the layout settings of the selection frame.
Tags
tags
The user-defined tags for this view.
(Inherited from DecoratorView<T>)
Tooltip
tooltip
Tooltip data to display on hover, if any.
(Inherited from DecoratorView<T>)
Transform
transform
Local transformation to apply to this view, including any children and floating elements.
(Inherited from DecoratorView<T>)
TransformOrigin
transform-origin
Relative origin position for any Transform on this view.
(Inherited from DecoratorView<T>)
View
view
(Inherited from ComponentView<T>)
Visibility
visibility
Drawing visibility for this view.
(Inherited from DecoratorView<T>)
ZIndex
z-index
Z order for this view within its direct parent. Higher indices draw later (on top).
(Inherited from DecoratorView<T>)

Methods

Name Description
ContainsPoint(Vector2) Checks if a given point, relative to the view's origin, is within its bounds.
(Inherited from DecoratorView<T>)
CreateView() Creates and returns the root view.
(Overrides ComponentView<T>.CreateView())
Dispose() (Inherited from DecoratorView<T>)
Draw(ISpriteBatch) Draws the content for this view.
(Inherited from DecoratorView<T>)
FocusSearch(Vector2, Direction) Finds the next focusable component in a given direction that does not overlap with a current position.
(Inherited from DecoratorView<T>)
GetChildAt(Vector2, Boolean, Boolean) Finds the child at a given position.
(Inherited from DecoratorView<T>)
GetChildPosition(IView) Computes or retrieves the position of a given direct child.
(Inherited from DecoratorView<T>)
GetChildren(Boolean) Gets the current children of this view.
(Inherited from DecoratorView<T>)
GetChildrenAt(Vector2) Finds all children at a given position.
(Inherited from DecoratorView<T>)
GetDefaultFocusChild() Gets the direct child that should contain cursor focus when a menu or overlay containing this view is first opened.
(Inherited from DecoratorView<T>)
HasOutOfBoundsContent() Checks if the view has content or elements that are all or partially outside the ActualBounds.
(Inherited from DecoratorView<T>)
IsDirty() Checks whether or not the view is dirty - i.e. requires a new layout with a full Measure(Vector2).
(Inherited from DecoratorView<T>)
IsVisible(Vector2?) Checks if the view is effectively visible, i.e. if it has anything to draw.
(Inherited from DecoratorView<T>)
Measure(Vector2) Performs layout on this view, updating its OuterSize, ActualBounds and ContentBounds, and arranging any children in their respective positions.
(Overrides DecoratorView<T>.Measure(Vector2))
OnButtonPress(ButtonEventArgs) Called when a button press is received while this view is in the focus path.
(Inherited from DecoratorView<T>)
OnButtonRepeat(ButtonEventArgs) Called when a button press is first received, and at recurring intervals thereafter, for as long as the button is held and this view remains in the focus path.
(Inherited from DecoratorView<T>)
OnClick(ClickEventArgs) Called when a click is received within this view's bounds.
(Inherited from DecoratorView<T>)
OnDrag(PointerEventArgs) Called when the view is being dragged (mouse moved while left button held).
(Inherited from DecoratorView<T>)
OnDrop(PointerEventArgs) Called when the mouse button is released after at least one OnDrag(PointerEventArgs).
(Inherited from DecoratorView<T>)
OnLayout() Runs whenever layout occurs as a result of the UI elements changing.
(Inherited from DecoratorView<T>)
OnPointerMove(PointerMoveEventArgs) Called when a pointer movement related to this view occurs.
(Inherited from DecoratorView<T>)
OnPropertyChanged(PropertyChangedEventArgs) Raises the PropertyChanged event.
(Inherited from DecoratorView<T>)
OnPropertyChanged(string) Raises the PropertyChanged event.
(Inherited from DecoratorView<T>)
OnUpdate(TimeSpan) Runs on every update tick.
(Inherited from DecoratorView<T>)
OnWheel(WheelEventArgs) Called when a wheel event is received within this view's bounds.
(Inherited from DecoratorView<T>)
RegisterDecoratedProperty<TValue>(DecoratedProperty<T, TValue>) Registers a DecoratedProperty<T, TValue>.
(Inherited from DecoratorView<T>)
ScrollIntoView(IEnumerable<ViewChild>, Vector2) Attempts to scroll the specified target into view, including all of its ancestors, if not fully in view.
(Inherited from DecoratorView<T>)

Events

Name Description
ButtonPress Event raised when any button on any input device is pressed.
(Inherited from DecoratorView<T>)
ButtonRepeat Event raised when a button is being held while the view is in focus, and has been held long enough since the initial ButtonPress or the previous ButtonRepeat to trigger a repeated press.
(Inherited from DecoratorView<T>)
Click Event raised when the view receives a click initiated from any button.
(Inherited from DecoratorView<T>)
Drag Event raised when the view is being dragged using the mouse.
(Inherited from DecoratorView<T>)
DragEnd Event raised when mouse dragging is stopped, i.e. when the button is released. Always raised after the last Drag, and only once per drag operation.
(Inherited from DecoratorView<T>)
DragStart Event raised when mouse dragging is first activated. Always raised before the first Drag, and only once per drag operation.
(Inherited from DecoratorView<T>)
LeftClick Event raised when the view receives a click initiated from the left mouse button, or the controller's action button (A).
(Inherited from DecoratorView<T>)
PointerEnter Event raised when the pointer enters the view.
(Inherited from DecoratorView<T>)
PointerLeave Event raised when the pointer exits the view.
(Inherited from DecoratorView<T>)
PointerMove Event raised when the pointer moves within the view.
(Inherited from DecoratorView<T>)
PropertyChanged (Inherited from DecoratorView<T>)
RightClick Event raised when the view receives a click initiated from the right mouse button, or the controller's tool-use button (X).
(Inherited from DecoratorView<T>)
Select Event raised when an item in the list is selected.
Wheel Event raised when the scroll wheel moves.
(Inherited from DecoratorView<T>)

Details

Constructors

public DropDownList<T>();

Properties

MaxListHeight

Maximum height of the expanded list.

public float? MaxListHeight { get; set; }
Property Value

Nullable<Single>

Remarks

By default, the item list can expand all the way to the bottom of the viewport, and will scroll if it exceeds the full height; this can end up being very tall and difficult to navigate on large screens. Setting this to a smaller value will limit the height.

This affects only the list of items in the expanded state; it is different from the MaxHeight of the DropDownList<T>'s own Layout.


OptionFormat

Specifies how to format the SelectedOption in the label text.

public Func<T, string> OptionFormat { get; set; }
Property Value

Func<T, string>


OptionMaxLines

Maximum number of lines to allow per option in the drop-down list.

public int OptionMaxLines { get; set; }
Property Value

Int32

Remarks

Setting this allows options in the list to wrap lines instead of being truncated to one line. Applies only to the open list, and not the selected item text within the main border, which is always single-line.


OptionMinWidth

Minimum width for the text area of an option.

public float OptionMinWidth { get; set; }
Property Value

Single

Remarks

If this is 0, or if all options are larger, then the dropdown will expand horizontally.


Options

The options available to select.

public System.Collections.Generic.IReadOnlyList<T> Options { get; set; }
Property Value

IReadOnlyList<T>


SelectedIndex

Index of the currently-selected option in the Options, or -1 if none selected.

public int SelectedIndex { get; set; }
Property Value

Int32


SelectedOption

The option that is currently selected, or null if there is no selection.

public T SelectedOption { get; set; }
Property Value

T


SelectedOptionText

The text of the currently-selected option.

public string SelectedOptionText { get; }
Property Value

string


SelectionFrameLayout

Customizes the layout settings of the selection frame.

public StardewUI.Layout.LayoutParameters SelectionFrameLayout { get; set; }
Property Value

LayoutParameters

Remarks

The selection frame is the frame surrounding the text of the selected item, not including the dropdown button (arrow) itself which is fixed size. By default, the selection frame matches the width of the selected item text; this can be changed, for example, to stretch to the available layout width, minus the button.


Methods

CreateView()

Creates and returns the root view.

protected override StardewUI.IView CreateView();
Returns

IView


Measure(Vector2)

Performs layout on this view, updating its OuterSize, ActualBounds and ContentBounds, and arranging any children in their respective positions.

public override bool Measure(Microsoft.Xna.Framework.Vector2 availableSize);
Parameters

availableSize   Vector2
The width/height that is still available in the container/parent.

Returns

Boolean

Whether or not any layout was performed as a result of this pass. Callers may use this to propagate layout back up the tree, or perform expensive follow-up actions.

Remarks

Most views should save the value of availableSize for use in IsDirty() checks.


Events

Select

Event raised when an item in the list is selected.

public event EventHandler<System.EventArgs>? Select;
Event Type

EventHandler<EventArgs>