radiogroup (cellium v0.1.0)

View Source

Radio group widget — a labelled group of mutually exclusive radio buttons.

Renders a set of named options as radio buttons. Only one option can be selected at a time. The group can be laid out horizontally or vertically.

Usage

radiogroup:new(my_group, [opt_a, opt_b, opt_c])

Properties

  • options — list of atoms used as option identifiers and display labels
  • selected — atom identifying the currently selected option
  • orientationvertical (default) or horizontal
  • focusable — true by default

Display (vertical, opt_b selected)

( ) opt_a
(*) opt_b
( ) opt_c

Display (horizontal)

( ) opt_a  (*) opt_b  ( ) opt_c

Messages

When the user changes the selection the group sends:

{radiogroup_changed, GroupId, NewSelectedOption}

Summary

Functions

Moves selection or wraps around on arrow / space / enter key events.

Creates a vertical radiogroup with the given options. First option is selected by default.

Creates a radiogroup with the given options and orientation (vertical | horizontal).

Renders the radiogroup in unfocused state.

Renders the radiogroup with the selected option highlighted.

Functions

handle_event/2

-spec handle_event(term(), map()) -> map().

Moves selection or wraps around on arrow / space / enter key events.

new(Id, Options)

-spec new(term(), [atom()]) -> map().

Creates a vertical radiogroup with the given options. First option is selected by default.

new(Id, Options, Orientation)

-spec new(term(), [atom()], vertical | horizontal) -> map().

Creates a radiogroup with the given options and orientation (vertical | horizontal).

render(Widget, Buffer)

-spec render(map(), map()) -> map().

Renders the radiogroup in unfocused state.

render_focused(Widget, Buffer)

-spec render_focused(map(), map()) -> map().

Renders the radiogroup with the selected option highlighted.