1
0
mirror of https://github.com/rivo/tview.git synced 2025-04-24 13:48:56 +08:00

Added RemoveOption() and GetOptionCount() to DropDown. Resolves #682

This commit is contained in:
Oliver 2022-02-16 11:14:05 +01:00
parent 1560f6b730
commit f0544de1f2

View File

@ -267,6 +267,19 @@ func (d *DropDown) SetOptions(texts []string, selected func(text string, index i
return d
}
// GetOptionCount returns the number of options in the drop-down.
func (d *DropDown) GetOptionCount() int {
return len(d.options)
}
// RemoveOption removes the specified option from the drop-down. Panics if the
// index is out of range.
func (d *DropDown) RemoveOption(index int) *DropDown {
d.options = append(d.options[:index], d.options[index+1:]...)
d.list.RemoveItem(index)
return d
}
// SetSelectedFunc sets a handler which is called when the user changes the
// drop-down's option. This handler will be called in addition and prior to
// an option's optional individual handler. The handler is provided with the