segmented

package
v1.0.31-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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

func New(options ...string) *Control

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) Choose

func (c *Control) Choose(i int)

Choose selects option i and invokes OnChange, as a tap would.

func (*Control) Icons

func (c *Control) Icons(icons ...elements.Element) *Control

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

func (c *Control) OnChange(fn func(i int)) *Control

OnChange sets the handler called when the user picks an option. It returns c for chaining.

func (*Control) Options

func (c *Control) Options() []string

Options returns the options.

func (*Control) Selected

func (c *Control) Selected() int

Selected returns the selected option's index.

func (*Control) SetSelected

func (c *Control) SetSelected(i int)

SetSelected selects option i without invoking OnChange.

func (*Control) Styles

func (c *Control) Styles(st styles.Styles) *Control

Styles sets the styles. It returns c for chaining.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL