Improve handling of SelButtons. Reset password insertion page as

appropriate.
This commit is contained in:
Greg 2019-10-03 17:34:04 -04:00
parent e275ad6607
commit b0abb36e64
2 changed files with 33 additions and 2 deletions

View File

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

View File

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