mirror of https://github.com/rivo/tview.git
EnableMouse to take bool and enable/disable directly
This commit is contained in:
parent
15700e7129
commit
55cdc84e25
|
@ -155,10 +155,17 @@ func (a *Application) SetScreen(screen tcell.Screen) *Application {
|
|||
}
|
||||
|
||||
// EnableMouse enables mouse events.
|
||||
func (a *Application) EnableMouse() *Application {
|
||||
func (a *Application) EnableMouse(enable bool) *Application {
|
||||
a.Lock()
|
||||
a.enableMouse = true
|
||||
a.Unlock()
|
||||
defer a.Unlock()
|
||||
if enable != a.enableMouse && a.screen != nil {
|
||||
if enable {
|
||||
a.screen.EnableMouse()
|
||||
} else {
|
||||
a.screen.DisableMouse()
|
||||
}
|
||||
}
|
||||
a.enableMouse = enable
|
||||
return a
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ func main() {
|
|||
AddItem("Quit", "Press to exit", 'q', func() {
|
||||
app.Stop()
|
||||
})
|
||||
app.EnableMouse()
|
||||
app.EnableMouse(true)
|
||||
if err := app.SetRoot(list, true).Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ func main() {
|
|||
return event
|
||||
})
|
||||
|
||||
app.EnableMouse()
|
||||
app.EnableMouse(true)
|
||||
|
||||
// Start the application.
|
||||
if err := app.SetRoot(layout, true).Run(); err != nil {
|
||||
|
|
Loading…
Reference in New Issue