Documentation
¶
Index ¶
- type Control
- func (c *Control) Choose(i int)
- func (c *Control) Icons(icons ...elements.Element) *Control
- func (c *Control) Layout(gtx layout.Context) layout.Dimensions
- func (c *Control) OnChange(fn func(i int)) *Control
- func (c *Control) Options() []string
- func (c *Control) Selected() int
- func (c *Control) SetSelected(i int)
- func (c *Control) Styles(st styles.Styles) *Control
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Control ¶
type Control struct {
// Contextual gives it a context menu (Context).
elements.Contextual
// contains filtered or unexported fields
}
Control is a stateful segmented control. Create it once with New and lay it out every frame.
func New ¶
New returns a control with the given options, the first selected. The styles argument is optional: Background is the track (default a faint tint of the text), BorderColor the selected segment (default theme.surface), Color the labels (default theme.text), FontSize, and Width: -1 to fill the row with equal segments, or a fixed width they share equally.
func (*Control) Icons ¶
Icons sets an icon per option, shown before its label (or alone for an empty label); nil entries have none. It returns c for chaining.
func (*Control) Layout ¶
func (c *Control) Layout(gtx layout.Context) layout.Dimensions
Layout lays out and updates the control.
func (*Control) OnChange ¶
OnChange sets the handler called when the user picks an option. It returns c for chaining.
func (*Control) SetSelected ¶
SetSelected selects option i without invoking OnChange.