mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
widget: report whether Value changed after Enum.Update and Bool.Update
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+5
-2
@@ -14,8 +14,10 @@ type Bool struct {
|
||||
gesture gesture.Click
|
||||
}
|
||||
|
||||
// Update the checked state according to incoming events.
|
||||
func (b *Bool) Update(gtx *layout.Context) {
|
||||
// Update the checked state according to incoming events,
|
||||
// and reports whether Value changed.
|
||||
func (b *Bool) Update(gtx *layout.Context) bool {
|
||||
was := b.Value
|
||||
for _, e := range b.gesture.Events(gtx) {
|
||||
switch e.Type {
|
||||
case gesture.TypeClick:
|
||||
@@ -26,6 +28,7 @@ func (b *Bool) Update(gtx *layout.Context) {
|
||||
b.Value = !b.Value
|
||||
}
|
||||
}
|
||||
return b.Value != was
|
||||
}
|
||||
|
||||
func (b *Bool) Layout(gtx *layout.Context) {
|
||||
|
||||
Reference in New Issue
Block a user