SelectorWidget
The SelectorWidget
is a dropdown-style selection widget that allows users to pick an option from a predefined list. It supports dynamically updating the selection list, displaying a configurable UI, and handling selection changes efficiently.
Features
- Dropdown selection – Expands to show available choices.
- Event handling – Fires callbacks when the selection changes.
Properties
Field | Type | Description |
---|---|---|
currentValue |
String |
Currently selected option. |
APIs
setCandidates
Updates the list of selectable options.
- Triggers a UI update to reflect the new options.
setValue
Sets the currently selected value.
- If the value is not found in
candidates
, it remains unchanged.
setMaxCount
Defines how many options should be visible before scrolling.
- If there are more than
maxCount
options, a scrollbar is added.
setFontColor
Changes the color of option text.
setButtonBackground
Sets the background texture for the button area.
setOnChanged
Registers a callback to handle selection changes.
- This is useful for updating UI state or triggering game logic.
setCandidatesSupplier
Automatically updates the option list from a dynamic source.
- The widget polls this function to refresh the list.
- Useful when candidates change based on external conditions.
setShow
Manually toggles the dropdown visibility.