Documentation
¶
Overview ¶
Package checkbox provides a stateful checkbox with an optional label.
Index ¶
- type Checkbox
- func (c *Checkbox) CacheSafe() bool
- func (c *Checkbox) Checked() bool
- func (c *Checkbox) Icon(src icon.Source, st ...styles.Styles) *Checkbox
- func (c *Checkbox) Layout(gtx layout.Context) layout.Dimensions
- func (c *Checkbox) OnChange(fn func(checked bool)) *Checkbox
- func (c *Checkbox) Outlined(on bool) *Checkbox
- func (c *Checkbox) SetChecked(v bool)
- func (c *Checkbox) Toggle()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checkbox ¶
type Checkbox struct {
// Contextual gives it a context menu (Context).
elements.Contextual
// contains filtered or unexported fields
}
Checkbox is a stateful checkbox with an optional label. Create it once with New and lay it out every frame.
func New ¶
New returns a Checkbox. label is optional: pass "" for a bare checkbox with no label. The styles argument is optional: Color is the label color, Background is the checked fill, BorderColor is the unchecked border, BorderWidth and BorderRadius the border, and Width/Height size the box (default 18x18).
func (*Checkbox) CacheSafe ¶
CacheSafe reports true: what it draws comes from its own fields, which the cache watches.
func (*Checkbox) Icon ¶
Icon replaces the check mark shown when checked with any icon.Source (a loaded SVG, a registered icon, path data). The styles argument is optional and overrides the icon's Color (default white) and size (defaults to the box size). Icon(nil) restores the built-in check mark.
func (*Checkbox) Layout ¶
func (c *Checkbox) Layout(gtx layout.Context) layout.Dimensions
Layout lays out and updates the checkbox.
func (*Checkbox) OnChange ¶
OnChange sets the handler invoked when the state changes. It returns c for chaining.
func (*Checkbox) Outlined ¶
Outlined draws a checked box as an outline in the Background colour with a check mark of the same colour, instead of filling it: for outline-only designs. It returns c for chaining.
func (*Checkbox) SetChecked ¶
SetChecked sets the state without invoking OnChange.