mirror of https://github.com/rivo/tview.git
Fire Selected on list item click
This commit is contained in:
parent
d7250288e2
commit
d891191b78
|
@ -15,6 +15,7 @@ func main() {
|
||||||
AddItem("Quit", "Press to exit", 'q', func() {
|
AddItem("Quit", "Press to exit", 'q', func() {
|
||||||
app.Stop()
|
app.Stop()
|
||||||
})
|
})
|
||||||
|
app.EnableMouse()
|
||||||
if err := app.SetRoot(list, true).Run(); err != nil {
|
if err := app.SetRoot(list, true).Run(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
12
list.go
12
list.go
|
@ -554,7 +554,17 @@ func (l *List) MouseHandler() func(event EventMouse) {
|
||||||
atX, atY := event.Position()
|
atX, atY := event.Position()
|
||||||
index := l.indexAtPoint(atX, atY)
|
index := l.indexAtPoint(atX, atY)
|
||||||
if index != -1 {
|
if index != -1 {
|
||||||
l.SetCurrentItem(index)
|
item := l.items[index]
|
||||||
|
if item.Selected != nil {
|
||||||
|
item.Selected()
|
||||||
|
}
|
||||||
|
if l.selected != nil {
|
||||||
|
l.selected(index, item.MainText, item.SecondaryText, item.Shortcut)
|
||||||
|
}
|
||||||
|
if index != l.currentItem && l.changed != nil {
|
||||||
|
l.changed(index, item.MainText, item.SecondaryText, item.Shortcut)
|
||||||
|
}
|
||||||
|
l.currentItem = index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue