Tweak SelButton.
This commit is contained in:
parent
0f984918ea
commit
fdb655c671
|
@ -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}
|
||||||
|
|
|
@ -134,10 +134,26 @@ func (b *Button) Clicked() bool {
|
||||||
return b.clicked
|
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 {
|
func (b *SelButton) Clicked() bool {
|
||||||
if b.clicked {
|
if b.clicked {
|
||||||
b.Selected = !b.Selected
|
b.Toggle()
|
||||||
b.SelColor, b.Background = b.Background, b.SelColor
|
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue
Block a user