From 05fc3ef43336bfc70d92b89c3d0054907dab7e43 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 9 Aug 2020 19:00:22 +0200 Subject: [PATCH] cmd/tailscale: close overflow menu when the Android back button is pressed Signed-off-by: Elias Naur --- cmd/tailscale/main.go | 6 ++++++ cmd/tailscale/ui.go | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/cmd/tailscale/main.go b/cmd/tailscale/main.go index 4af3fa4..d4a8e2a 100644 --- a/cmd/tailscale/main.go +++ b/cmd/tailscale/main.go @@ -550,6 +550,12 @@ func (a *App) runUI() error { switch e := e.(type) { case system.DestroyEvent: return e.Err + case *system.CommandEvent: + if e.Type == system.CommandBack { + if ui.onBack() { + e.Cancel = true + } + } case system.FrameEvent: gtx := layout.NewContext(&ops, e) events := ui.layout(gtx, e.Insets, state) diff --git a/cmd/tailscale/ui.go b/cmd/tailscale/ui.go index ae0def6..46916c6 100644 --- a/cmd/tailscale/ui.go +++ b/cmd/tailscale/ui.go @@ -168,6 +168,14 @@ func newUI(store *stateStore) (*UI, error) { return ui, nil } +func (ui *UI) onBack() bool { + if !ui.menu.show { + return false + } + ui.menu.show = false + return true +} + func (ui *UI) layout(gtx layout.Context, sysIns system.Insets, state *clientState) []UIEvent { ui.events = nil if ui.enabled.Changed() {