diff --git a/cmd/passgo-gui/main.go b/cmd/passgo-gui/main.go index cf2aeff..08b0a06 100644 --- a/cmd/passgo-gui/main.go +++ b/cmd/passgo-gui/main.go @@ -491,12 +491,14 @@ func eventLoop() { } var insName, insValue string - genBtn := &SelButton{SelColor: darkgray} - genBtn.Button = Button{Size: unit.Sp(16), Label: "generate", Background: gray} - symBtn := &SelButton{SelColor: gray, Selected: true} - numBtn := &SelButton{SelColor: gray, Selected: true} - symBtn.Button = Button{Size: unit.Sp(16), Label: "@", Background: darkgray} - numBtn.Button = Button{Size: unit.Sp(16), Label: "#", Background: darkgray} + genBtn := &SelButton{SelColor: gray} + genBtn.Button = Button{Size: unit.Sp(16), Label: "generate"} + symBtn := &SelButton{SelColor: gray} + numBtn := &SelButton{SelColor: gray} + symBtn.Button = Button{Size: unit.Sp(16), Label: "@"} + numBtn.Button = Button{Size: unit.Sp(16), Label: "#"} + symBtn.Select() + numBtn.Select() lenEd := &text.Editor{Size: unit.Sp(16), Family: family, SingleLine: true, Alignment: text.End} lenEd.SetText("15") lBtn := &Button{Size: unit.Sp(16), Label: "<", Background: gray} diff --git a/cmd/passgo-gui/ui.go b/cmd/passgo-gui/ui.go index 8a7fac4..7b8c3b5 100644 --- a/cmd/passgo-gui/ui.go +++ b/cmd/passgo-gui/ui.go @@ -134,10 +134,26 @@ func (b *Button) Clicked() bool { return b.clicked } +func (b *SelButton) Toggle() { + b.Selected = !b.Selected + b.SelColor, b.Background = b.Background, b.SelColor +} + +func (b *SelButton) Select() { + if !b.Selected { + b.Toggle() + } +} + +func (b *SelButton) Deselect() { + if b.Selected { + b.Toggle() + } +} + 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