Skip to main content

Function: addUiDropdownComponent()

addUiDropdownComponent(world, entity, options): UiDropdownEcsComponent

Defined in: ui/components/ui-dropdown-component.ts:63

Attaches a UiDropdownEcsComponent to entity. Prefer createDropdown, which builds the header/option-row entities this component's isOpen/selectedIndex transitions are wired against - this is exposed mainly for createDropdown's own use and for tests.

Parameters​

world​

EcsWorld

The ECS world entity belongs to.

entity​

number

The entity to attach the component to.

options​

UiDropdownRequiredOptions & Partial<UiDropdownDefaultedOptions>

Options for configuring the dropdown. options has no sensible default and must always be provided, and must be non-empty.

Returns​

UiDropdownEcsComponent

The attached component.

Throws​

An error if options.options is empty, or if selectedIndex is out of bounds for it.