diff --git a/cmd/passgo-gui/main.go b/cmd/passgo-gui/main.go index 6e8574a..635e71d 100644 --- a/cmd/passgo-gui/main.go +++ b/cmd/passgo-gui/main.go @@ -504,6 +504,12 @@ func eventLoop() { passvalEd.SetText(string(pw)) } + resetInsertPage := func() { + passnameEd.SetText("") + passvalEd.SetText("") + genBtn.Deselect() + } + insertPage = func() { c2 := flex.End(insertLabel.Layout(ops, flex.Rigid())) @@ -560,6 +566,7 @@ func eventLoop() { } if backBtn.Clicked() { w.Invalidate() + resetInsertPage() page = listPage } if saveBtn.Clicked() { @@ -597,6 +604,7 @@ func eventLoop() { if yesBtn.Clicked() { w.Invalidate() page = listPage + resetInsertPage() store.Insert(insName, insValue) } } diff --git a/cmd/passgo-gui/ui.go b/cmd/passgo-gui/ui.go index a50ca08..3fdc74f 100644 --- a/cmd/passgo-gui/ui.go +++ b/cmd/passgo-gui/ui.go @@ -134,10 +134,33 @@ func (b *Button) Clicked() bool { return b.clicked } +func (b *SelButton) Select() { + if b.Selected { + return + } + b.Selected = true + b.SelColor, b.Background = b.Background, b.SelColor +} + +func (b *SelButton) Deselect() { + if !b.Selected { + return + } + b.Selected = false + b.SelColor, b.Background = b.Background, b.SelColor +} + +func (b *SelButton) Toggle() { + if b.Selected { + b.Deselect() + } else { + b.Select() + } +} + func (b *SelButton) Clicked() bool { if b.clicked { - b.Selected = !b.Selected - b.SelColor, b.Background = b.Background, b.SelColor + b.Toggle() return true } else { return false