UIDropdown¶
Classes¶
- UIDropDown : UIComponent¶
A drop-down list component that can be used to select an item from a list.
Usage example:
def init_dropdown() {
get_component(node) $(var dropdown : UIDropDown?) {
dropdown.items = ["Option 1", "Option 2", "Option 3"]
dropdown.onChange = @(newIndex : int) { print("Selected index changed to {newIndex}") }
}
}
- Fields:
items : array<string> - List of items to display in the dropdown.
dropdownNode : NodeId - Node that appears when the dropdown is opened. It should likely either be the same node as
itemsContainerNodeor one of its parents.itemsContainerNode : NodeId - Node that will be the parent for dropdown item nodes. If not set, dropdownNode will be used.
textField : UIText? - The text field component to display the selected item.
itemPrefab : PrefabId - Prefab for the dropdown items (should have UIText and UIFrame components).
onChange : lambda<(index:int):void> - Called when the selection changes.
- UIDropDown.on_initialize()¶
Initializes the drop-down list and sets up button handlers.
- UIDropDown.on_update()¶
Updates the drop-down list if the items have changed.
- UIDropDown.select(newIndex: int; doFade: bool)¶
Sets the selected index and updates UI.
- Arguments:
newIndex : int
doFade : bool
- UIDropDown.invalidate(doFade: bool)¶
Updates the displayed selected item text.
- Arguments:
doFade : bool
- UIDropDown.toggle_dropdown()¶
Toggles the drop-down list open/closed.
- UIDropDown.open_dropdown()¶
Opens the drop-down list.
- UIDropDown.close_dropdown()¶
Closes the drop-down list.
- Properties:
- UIDropDown.selectedIndex: int¶
Returns the currently selected index.
- UIDropDown.selectedIndex =(newIndex: int)¶
Sets the selected index and updates UI.
- Arguments:
newIndex : int
- UIDropDown.itemNodes: array<NodeId>¶
Returns the list of item nodes.