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 var insName, insValue string
genBtn := &SelButton{SelColor: darkgray} genBtn := &SelButton{SelColor: gray}
genBtn.Button = Button{Size: unit.Sp(16), Label: "generate", Background: gray} genBtn.Button = Button{Size: unit.Sp(16), Label: "generate"}
symBtn := &SelButton{SelColor: gray, Selected: true} symBtn := &SelButton{SelColor: gray}
numBtn := &SelButton{SelColor: gray, Selected: true} numBtn := &SelButton{SelColor: gray}
symBtn.Button = Button{Size: unit.Sp(16), Label: "@", Background: darkgray} symBtn.Button = Button{Size: unit.Sp(16), Label: "@"}
numBtn.Button = Button{Size: unit.Sp(16), Label: "#", Background: darkgray} 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 := &text.Editor{Size: unit.Sp(16), Family: family, SingleLine: true, Alignment: text.End}
lenEd.SetText("15") lenEd.SetText("15")
lBtn := &Button{Size: unit.Sp(16), Label: "<", Background: gray} lBtn := &Button{Size: unit.Sp(16), Label: "<", Background: gray}

View File

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