pub struct Radio {
pub id: Option<NodeId>,
pub checked: bool,
pub on_select: Option<ActionEnvelope>,
pub label: Option<String>,
}Expand description
A single-select radio button with a circular indicator and optional label.
Radio buttons are typically used in a group where exactly one is selected
at a time. The on_select action is dispatched when the user taps the
button; the application updates which option is selected in the reducer.
§Example
ⓘ
for (i, option) in options.iter().enumerate() {
let on_select = ctx.bind(
SelectOption { index: i },
reduce_with!(handle_select),
);
children.push(Radio {
checked: view.state.selected == i,
on_select: Some(on_select),
label: Some(option.clone()),
..Default::default()
}.into_node().into());
}Fields§
§id: Option<NodeId>Explicit node identity.
checked: boolWhether this radio button is currently selected.
on_select: Option<ActionEnvelope>Action dispatched when this radio button is tapped.
label: Option<String>Optional text label rendered next to the indicator.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Radio
impl<'de> Deserialize<'de> for Radio
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Lower for Radio
impl Lower for Radio
Source§fn lower(&self, cx: &mut LoweringContext<'_>) -> NodeId
fn lower(&self, cx: &mut LoweringContext<'_>) -> NodeId
Lower this widget into the IR, returning the root node id.
Auto Trait Implementations§
impl Freeze for Radio
impl RefUnwindSafe for Radio
impl Send for Radio
impl Sync for Radio
impl Unpin for Radio
impl UnsafeUnpin for Radio
impl UnwindSafe for Radio
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.