DropDownList
The DropDownList element extends the View interface and is designed to select a value from a drop-down list.
To create a DropDownList, use the function:
func NewDropDownList(session Session, params Params) DropDownList
The list of possible values is set using the "items" property (Items constant).The following data types can be passed as a value to the "items" property
- []string
- []fmt.Stringer
- []any containing as elements only: string, fmt.Stringer, bool, rune,float32, float64, int, int8 … int64, uint, uint8 … uint64.
All of these data types are converted to []string and assigned to the "items" property.You can read the value of the "items" property using the function
func GetDropDownItems(view View, subviewID ...string) []string
You can disable the selection of individual items. For this, the "disabled-items" property (constant DisabledItems) is used.This property is assigned an array of disabled item indices. The index can be specified either as a number, as text, or as a constant. Therefore, the following data types can be assigned to the "disabled-items" property:
- []int
- int
- []string
- string - can contain multiple indexes separated by commas
- []any - containing as elements only: string, int, int8…int64, uint, uint8…uint64.
All of these data types are converted to []any and assigned to the "disabled-items" property.You can read the value of the "disabled-items" property using the function
func GetDropDownDisabledItems(view View, subviewID ...string) []int
The selected value is determined by the int property "current" (Current constant). The default is 0.You can read the value of this property using the function
func GetCurrent(view View, subviewID ...string) int
To track the change of the "current" property, the "drop-down-event" event (DropDownEvent constant) is used.The main event listener has the following format:
func(list DropDownList, newCurrent int)
where the second argument is the index of the selected item, the third argument is the previous index value.
Additional event listeners can have the following format
func(list DropDownList, newCurrent int) func(newCurrent, oldCurrent int) func(newCurrent int) func(list DropDownList) func()
You can get the current list of date change listeners using the function
func GetDropDownListeners(view View, subviewID ...string) []func(DropDownList, int, int)