mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
4ac3a7fd84
Signed-off-by: Alexander Arin <fralx@yandex.ru>
30 lines
465 B
Go
30 lines
465 B
Go
package widget
|
|
|
|
import (
|
|
"gioui.org/gesture"
|
|
"gioui.org/layout"
|
|
)
|
|
|
|
type CheckBox struct {
|
|
click gesture.Click
|
|
checked bool
|
|
}
|
|
|
|
func (c *CheckBox) SetChecked(value bool) {
|
|
c.checked = value
|
|
}
|
|
|
|
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)
|
|
}
|