View Source Scenic.Component.Input.RadioGroup (Scenic v0.11.2)
Add a radio group to a graph
The data format for RadioGroup has changed since v0.10!
data
Data
{radio_buttons, checked_id}
radio_buttons
must be a list of radio button data. See below.checked_id
Is the id of the currently selected radio from the list.
radio_buttons list:
{text, radio_id}
text
- must be a bitstringbutton_id
- can be any term you want. It will be passed back to you as the group's value.checked?
- must be a boolean and indicates if the button is selected.checked?
is not required and will default tofalse
if not supplied.
Example showing the full data format
{[{"One", :one}, {"Two", :two}, {"Three", :three}], :two}
messages
Messages
When the state of the radio group changes, it sends an event message to the host scene in the form of:
{:value_changed, id, radio_id}
options
Options
Radio Buttons honor the following list of options.
:theme
- This sets the color scheme of the button. This can be one of pre-defined button schemes:light
,:dark
, or it can be a completely custom scheme like this:{text_color, box_background, border_color, pressed_color, checkmark_color}
.
styles
Styles
Radio Buttons honor the following styles
:hidden
- Iffalse
the component is rendered. Iftrue
, it is skipped. The default isfalse
.:theme
- The color set used to draw. See below. The default is:dark
theme
Theme
Radio buttons work well with the following predefined themes: :light
,
:dark
To pass in a custom theme, supply a map with at least the following entries:
:text
- the color of the text:background
- the background of the component:border
- the border of the component:active
- the background of the circle while the button is pressed:thumb
- the color of inner selected-mark
usage
Usage
You should add/modify components via the helper functions in
Scenic.Components
examples
Examples
The following example creates a radio group and positions it on the screen.
graph
|> radio_group({[
{"Radio A", :radio_a},
{"Radio B", :radio_b},
{"Radio C", :radio_c},
], :radio_b},
id: :radio_group_id, translate: {20, 20})
Link to this section Summary
Functions
Callback implementation for Scenic.Component.add_to_graph/3
.
Returns a specification to start this module under a supervisor.
Link to this section Functions
Callback implementation for Scenic.Component.add_to_graph/3
.
Returns a specification to start this module under a supervisor.
See Supervisor
.