From 54c2c00455812dbf897071a6244c0a7f7588eac2 Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 17 Sep 2020 20:18:20 -0400 Subject: [PATCH] Add 'X' button to password filter. --- cmd/passgo-gui/main.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cmd/passgo-gui/main.go b/cmd/passgo-gui/main.go index 5c5cbd0..45af325 100644 --- a/cmd/passgo-gui/main.go +++ b/cmd/passgo-gui/main.go @@ -376,6 +376,13 @@ func eventLoop() { Color: black, Background: gray, } + xBtn := &Button{ + Size: unit.Sp(fontSize), + Label: "X", + Alignment: text.Middle, + Color: black, + Background: gray, + } insertLabel := material.Label(th, unit.Sp(fontSize), "Insert") passnameLabel := material.Label(th, unit.Sp(fontSize), "password name:") @@ -410,6 +417,7 @@ func eventLoop() { return <-passch } + lpf1 := &layout.Flex{Axis: layout.Horizontal} listPage = func(gtx C) D { // timing variables used for animation fade1a, fade1b := 1.5, 2.0 @@ -417,7 +425,17 @@ func eventLoop() { fade2a, end := start2+1.5, start2+2.0 c2 := layout.Rigid(func(gtx C) D { - return material.Editor(th, FilterEd, "filter").Layout(gtx) + c21 := layout.Flexed(1, func(gtx C) D { + return material.Editor(th, FilterEd, "filter").Layout(gtx) + }) + c22 := layout.Rigid(func(gtx C) D { + return xBtn.Layout(gtx) + }) + if xBtn.Clicked() { + FilterEd.SetText("") + updateBtns() + } + return lpf1.Layout(gtx, c21, c22) }) c3 := layout.Flexed(1.0, func(gtx C) D { var ret D