Documentation
¶
Overview ¶
Package checkbox implements an interactive checkbox widget.
Index ¶
- Variables
- type ChangeFn
- type Checkbox
- func (c *Checkbox) Checked() bool
- func (c *Checkbox) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error
- func (c *Checkbox) Keyboard(k *terminalapi.Keyboard, meta *widgetapi.EventMeta) error
- func (c *Checkbox) Mouse(m *terminalapi.Mouse, meta *widgetapi.EventMeta) error
- func (c *Checkbox) Options() widgetapi.Options
- func (c *Checkbox) SetChecked(checked bool)
- func (c *Checkbox) Text() string
- func (c *Checkbox) TextFor(checked bool) string
- func (c *Checkbox) Toggle() bool
- type IndicatorSet
- type Option
- func CellOpts(cellOpts ...cell.Option) Option
- func Checked(checked bool) Option
- func CheckedCellOpts(cellOpts ...cell.Option) Option
- func FocusedCellOpts(cellOpts ...cell.Option) Option
- func Indicators(unchecked, checked string) Option
- func LabelGap(cells int) Option
- func OnChange(fn ChangeFn) Option
- func UseIndicatorSet(set IndicatorSet) Option
Constants ¶
This section is empty.
Variables ¶
var ( DefaultTextColor = cell.ColorWhite DefaultFocusedTextColor = cell.ColorCyan DefaultCheckedTextColor = cell.ColorGreen )
Default colors used by the checkbox widget.
var IndicatorSets = struct { Classic IndicatorSet Heavy IndicatorSet Rounded IndicatorSet }{ Classic: IndicatorSet{Unchecked: "[ ]", Checked: "[x]"}, Heavy: IndicatorSet{Unchecked: "☐", Checked: "☑"}, Rounded: IndicatorSet{Unchecked: "◯", Checked: "◉"}, }
IndicatorSets groups reusable checkbox indicators.
Functions ¶
This section is empty.
Types ¶
type ChangeFn ¶
ChangeFn is called when the user toggles the checkbox state.
The callback must be thread-safe because it is triggered from the keyboard and mouse event handling paths, which run in separate goroutines.
type Checkbox ¶
type Checkbox struct {
// contains filtered or unexported fields
}
Checkbox lets the user toggle a single boolean value.
Implements widgetapi.Widget. This object is thread-safe.
func (*Checkbox) Keyboard ¶
Keyboard processes keyboard events for the checkbox. Implements widgetapi.Widget.Keyboard.
func (*Checkbox) Mouse ¶
Mouse processes mouse events for the checkbox. Implements widgetapi.Widget.Mouse.
func (*Checkbox) SetChecked ¶
SetChecked replaces the current checked state.
type IndicatorSet ¶
IndicatorSet defines the UTF-8 strings used to represent unchecked and checked states.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to provide options.
func CheckedCellOpts ¶
CheckedCellOpts sets the styling used while the checkbox is checked.
func FocusedCellOpts ¶
FocusedCellOpts sets the styling used while the checkbox is focused and unchecked.
func Indicators ¶
Indicators sets the UTF-8 strings used for unchecked and checked states.
func OnChange ¶
OnChange sets the checkbox's toggle hook.
This is the widget's canonical callback surface. Callers that need delayed or asynchronous behavior should build that from this hook so the widget keeps a single stable event path.
func UseIndicatorSet ¶
func UseIndicatorSet(set IndicatorSet) Option
UseIndicatorSet sets both checkbox indicator strings from a reusable group.
Directories
¶
| Path | Synopsis |
|---|---|
|
Binary checkboxdemo shows the functionality of a checkbox widget.
|
Binary checkboxdemo shows the functionality of a checkbox widget. |