diff --git a/application.go b/application.go index 3ef4e29..14823f3 100644 --- a/application.go +++ b/application.go @@ -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 } diff --git a/demos/list/main.go b/demos/list/main.go index 3ca90eb..07afa28 100644 --- a/demos/list/main.go +++ b/demos/list/main.go @@ -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) } diff --git a/demos/presentation/main.go b/demos/presentation/main.go index f72687b..1861780 100644 --- a/demos/presentation/main.go +++ b/demos/presentation/main.go @@ -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 {