Files
gio/widget/checkbox.go
T
Elias Naur 52d8a8867d widget,widget/material: export CheckBox.Checked
Similar to the previous change to Enum, expose the current state of
the CheckBox. Rename the Checked method to just Update and get rid
of the SetChecked method.

Fixes gio#100

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-03 21:28:33 +02:00

27 lines
432 B
Go

package widget
import (
"gioui.org/gesture"
"gioui.org/layout"
)
type CheckBox struct {
Checked bool
click gesture.Click
}
// Update the checked state according to incoming events.
func (c *CheckBox) Update(gtx *layout.Context) {
for _, e := range c.click.Events(gtx) {
switch e.Type {
case gesture.TypeClick:
c.Checked = !c.Checked
}
}
}
func (c *CheckBox) Layout(gtx *layout.Context) {
c.click.Add(gtx.Ops)
}