mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
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>
This commit is contained in:
+6
-9
@@ -6,22 +6,19 @@ import (
|
||||
)
|
||||
|
||||
type CheckBox struct {
|
||||
click gesture.Click
|
||||
checked bool
|
||||
Checked bool
|
||||
|
||||
click gesture.Click
|
||||
}
|
||||
|
||||
func (c *CheckBox) SetChecked(value bool) {
|
||||
c.checked = value
|
||||
}
|
||||
|
||||
func (c *CheckBox) Checked(gtx *layout.Context) bool {
|
||||
// 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
|
||||
c.Checked = !c.Checked
|
||||
}
|
||||
}
|
||||
return c.checked
|
||||
}
|
||||
|
||||
func (c *CheckBox) Layout(gtx *layout.Context) {
|
||||
|
||||
Reference in New Issue
Block a user