feat(ui): add ListBox.SetSelected()
this function will set the selected widget without triggering a onSelect event.
This commit is contained in:
parent
46552f0ed2
commit
f3d7995bc2
1 changed files with 8 additions and 1 deletions
|
|
@ -42,12 +42,19 @@ func (lb ListBox) Entries() []ui.InputWidget {
|
|||
}
|
||||
|
||||
func (lb *ListBox) Select(index int) {
|
||||
if lb.SetSelected(index) {
|
||||
lb.onSelect()
|
||||
}
|
||||
}
|
||||
|
||||
func (lb *ListBox) SetSelected(index int) bool {
|
||||
if index >= 0 && index < len(lb.entries) {
|
||||
lb.entries[lb.selected].SetFocus(false)
|
||||
lb.selected = index
|
||||
lb.entries[lb.selected].SetFocus(true)
|
||||
lb.onSelect()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (lb ListBox) Selected() ui.InputWidget {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue