mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 08:25:34 +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
@@ -21,8 +21,10 @@ func index(vs []string, t string) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
// Update the Value according to incoming events.
|
||||
func (e *Enum) Update(gtx *layout.Context) {
|
||||
// Update the Value according to incoming events, and
|
||||
// reports whether Value changed.
|
||||
func (e *Enum) Update(gtx *layout.Context) bool {
|
||||
was := e.Value
|
||||
for i := range e.clicks {
|
||||
for _, ev := range e.clicks[i].Events(gtx) {
|
||||
switch ev.Type {
|
||||
@@ -31,6 +33,7 @@ func (e *Enum) Update(gtx *layout.Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return e.Value != was
|
||||
}
|
||||
|
||||
// Layout adds the event handler for key.
|
||||
|
||||
Reference in New Issue
Block a user