D3vugu-components/components/input/check-box.go
David Vogel 2f8a3b5016 Add CheckBox and RadioButton input components
- Add support for *bool to FieldBindAny
- Update example page PageInput
2023-06-23 20:41:04 +02:00

28 lines
427 B
Go

package input
import (
"github.com/vugu/vugu"
)
// CheckBox is a boolean type input component.
// Similar to a button that can be toggled.
type CheckBox struct {
AttrMap vugu.AttrMap
Bind *bool
}
func (c *CheckBox) isChecked() bool {
if c.Bind != nil {
return *c.Bind
}
return false
}
func (c *CheckBox) handleChange(event vugu.DOMEvent) {
if c.Bind != nil {
*c.Bind = event.PropBool("target", "checked")
}
}