Skip to content

Reference Radio Button

ddbnl edited this page Sep 2, 2022 · 1 revision

A simple switch that can be toggled on and off. A radio button is always 5 width and 1 height. A radio button can be part of a group (by setting the group property of multiple radio buttons to the same value). A group of radio buttons is mutually exclusive, meaning that when one becomes active, the others become inactive. Often used with on_value_change callbacks. Only the radio button that become active triggers an on_value_change callback.

Properties

active

Property that represents whether the radio button is on (active) or off.

Property type:

bool

Possible values:

  • true
  • false

Default value:

false

Usage examples:

In EzLang files:

- Radiobutton:
    active: true

In code:

use ez_term::*;
let (root_widget, mut state_tree, mut scheduler) = load_ui();
let state = state_tree.get_mut("my_radio_button").as_radio_button_mut();

state.set_active(true);

run(root_widget, state_tree, scheduler);

active_symbol

The symbol used to indicate the radio button is active. If for example the symbol is X, then the checkbox will look like this when active: ( X ).

Property type:

String

Possible values:

Any one character string.

Default value:

X

Usage examples:

In EzLang files:

- RadioButton:
    active_symbol: 0

In code:

use ez_term::*;
let (root_widget, mut state_tree, mut scheduler) = load_ui();
let state = state_tree.get_mut("my_radio_button").as_radio_button_mut();

state.set_active_symbol("0");

run(root_widget, state_tree, scheduler);

inactive_symbol

The symbol used to indicate the radio button is inactive. If for example the symbol is -, then the radio button will look like this when inactive: ( - ).

Property type:

String

Possible values:

Any one character string.

Default value:

Usage examples:

In EzLang files:

- RadioButton:
    inactive_symbol: .

In code:

use ez_term::*;
let (root_widget, mut state_tree, mut scheduler) = load_ui();
let state = state_tree.get_mut("my_radio_button").as_radio_button_mut();

state.set_inactive_symbol(".");

run(root_widget, state_tree, scheduler);

group

This property determines which radio buttons belong together, and are therefore mutually exclusive. Set multiple radio buttons to the same group value to make them part of the same group.

Property type:

String

Possible values:

Any string.

Default value:

Empty string

Usage examples:

In EzLang files:

- RadioButton:
    group: my_group

In code:

use ez_term::*;
let (root_widget, mut state_tree, mut scheduler) = load_ui();
let state = state_tree.get_mut("my_radio_button").as_radio_button_mut();

state.set_group("my_group");

run(root_widget, state_tree, scheduler);

Default callbacks implementations

on_left_click

Calls the on_press callback.

on_keyboard_enter

Calls the on_press callback.

Available callbacks

  • on_value_change (only if radio button became active)
  • on_keyboard_enter
  • on_press
  • on_select
  • on_deselect
  • on_scroll_up
  • on_scroll_down
  • on_hover
  • on_drag
  • on_left_click
  • on_right_click
  • Custom keys

Tutorial Tutorial-Project-Structure
  Minimal example
EzLang
  EzLang basics
  EzLang Templates
  Ezlang Layout modes
   EzLang Box mode layouts
   EzLang Stack mode layouts
   EzLang Table mode layouts
   EzLang Float mode layouts
   EzLang Tab mode layouts
   EzLang Screen mode layouts
   EzLang Layout Scrolling
   EzLang Layout Views
  EzLang Widget overview
   EzLang Label
   EzLang Text Input
   EzLang Button
   EzLang Checkbox
   EzLang Radio button
   EzLang Dropdown
   EzLang Slider
   EzLang Canvas
  EzLang Property Binding
  EzLang Sizing
   EzLang Size hints
   EzLang Auto scaling
   EzLang Maths Sizing
   EzLang Manual Sizing
  EzLang Positioning
   EzLang Layout Mode Positioning
   EzLang Position Hints
   EzLang Position Maths
   EzLang Manual Position
   EzLang Adjusting Position
  EzLang Keyboard Selection
Scheduler
  Widget States and the State Tree
  The Scheduler Object
  Managing callbacks
   Callback Structure
   Callback Configs
   Callback: On keyboard enter
   Callback: On Left Mouse Click
   Callback: On Press
   Callback: On Select
   Callback: On Deselect
   Callback: On Right Mouse Click
   Callback: On Hover
   Callback: On Drag
   Callback: On Scroll Up
   Callback: On Scroll Down
   Callback: On Value Change
   Callback: Custom Key Binds
   Callback: Global Key Binds
   Callback: Property Binds
  Tasks
   Scheduled Single Exectution Tasks
   Scheduled Recurring Tasks
   Threaded Tasks
  Custom Properties
  Modals
  Programmatic Widgets
  Updating widgets
  Managing selection
Default global (key)binds
Performance
ExamplesLayout: Box Mode Nested
Layout: Box Mode Size Hints
Layout: Stack Mode
Layout: Table Mode Dynamic
Layout: Table Mode Static
Layout: Float Mode Manual
Layout: Float Mode Position hints
Layout: Screen Mode
Layout: Tab Mode
Layout: Scrolling
Layout: Views
Widget: Label
Widget: Text input
Widget: Button
Widget: Checkbox
Widget: Radio Button
Widget: Dropdown
Widget: Slider
Widget: Progress Bar
Widget: Canvas
Scheduler: Schedule Once
Scheduler: Schedule Once Callback
Scheduler: Schedule Recurring
Scheduler: Schedule Recurring Callback
Scheduler: Threaded Task State Tree
Scheduler: Threaded Task Custom Property
Scheduler: Create Widgets
Scheduler: Modal Popup
Reference Widgets
  Common Properties
  Label
  Text Input
  Button
  Checkbox
  Radio button
  Dropdown
  Slider
  Canvas
Scheduler
  Schedule once
  Schedule Recurring
  Schedule Threaded
  Cancel Task
  Cancel Recurring Task
  Create Widget
  Remove Widget
  Select Widget
  Deselect Widget
  Update Widget
  Force Redraw
  Open Modal
  Dismiss Modal
  Bind Global Key
  Remove Global Key
  Clear Global Keys
  Bind Property
  Create Custom Properties
  Get Property
  Get Property Mut
  Overwrite Callback Config
  Update Callback Config
  Exit
Clone this wiki locally