EnableMouse to take bool and enable/disable directly

pull/363/head
Chris Miller 4 years ago
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…
Cancel
Save