Documentation
¶
Overview ¶
Package button renders a horizontal row of focusable buttons - "No Yes", or a lone "OK" - the affordance a confirm dialog puts under its prompt. One button holds focus; the arrow keys (via Row.Step) move it with wrap, and Row.Hit maps a clicked column back to a button so a mouse can press one directly.
Like pill and titlebox it is style-agnostic: each button carries its own focused and blurred styles, so a caller renders a green Yes and a red No - or any other pair - without the package knowing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Button ¶
Button is one pressable label with its two looks. The focused style renders when the button holds the row's focus, the blurred style otherwise; padding and background belong to the styles, so a pill-shaped button is just a style with a background and Padding(0, 1).
type Row ¶
type Row struct {
Buttons []Button
// Focus is the focused button's index; out-of-range renders every button
// blurred.
Focus int
// Gap separates adjacent buttons; empty means two spaces.
Gap string
}
Row is an ordered set of buttons with one focus. The zero value renders nothing and hits nothing.
func (*Row) Hit ¶
Hit returns the index of the button occupying column x of the rendered row (0-based from the row's first column), or -1 when x falls in a gap or outside the row. Widths are measured on the styled rendering, so a style's padding counts as pressable surface.