Tweak SelButton.

This commit is contained in:
Greg 2019-10-10 17:07:39 -04:00
parent 0f984918ea
commit fdb655c671
2 changed files with 26 additions and 8 deletions

View File

@ -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}

View File

@ -134,10 +134,26 @@ func (b *Button) Clicked() bool {
return b.clicked
}
func (b *SelButton) Clicked() bool {
if 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.Toggle()
return true
} else {
return false