mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
widget,widget/material: add CheckBox
This commit is contained in:
committed by
Elias Naur
parent
2a06f3d3b2
commit
0f5b94a483
@@ -0,0 +1,25 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user