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)) passvalEd.SetText(string(pw))
} }
resetInsertPage := func() {
passnameEd.SetText("")
passvalEd.SetText("")
genBtn.Deselect()
}
insertPage = func() { insertPage = func() {
c2 := flex.End(insertLabel.Layout(ops, flex.Rigid())) c2 := flex.End(insertLabel.Layout(ops, flex.Rigid()))
@ -560,6 +566,7 @@ func eventLoop() {
} }
if backBtn.Clicked() { if backBtn.Clicked() {
w.Invalidate() w.Invalidate()
resetInsertPage()
page = listPage page = listPage
} }
if saveBtn.Clicked() { if saveBtn.Clicked() {
@ -597,6 +604,7 @@ func eventLoop() {
if yesBtn.Clicked() { if yesBtn.Clicked() {
w.Invalidate() w.Invalidate()
page = listPage page = listPage
resetInsertPage()
store.Insert(insName, insValue) store.Insert(insName, insValue)
} }
} }

View File

@ -134,10 +134,33 @@ func (b *Button) Clicked() bool {
return b.clicked 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 { 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