Files
gio/widget/checkbox.go
T
2019-11-04 00:31:12 +01:00

26 lines
399 B
Go

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