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 for the dropdown list (should be a container node).

  • 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.