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:
parent
1560f6b730
commit
f0544de1f2
13
dropdown.go
13
dropdown.go
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user