Skip to main content

RadioGroup

Struct RadioGroup 

Source
pub struct RadioGroup<'a> { /* private fields */ }
Expand description

Radio group for single selection from multiple options

§Example

let mut selected = Some("option1".to_string());
let response = RadioGroup::new(&mut selected)
    .label("Choose one")
    .show(ui, |group| {
        group.option("option1", "First Option");
        group.option("option2", "Second Option")
            .description("This is the second option");
        group.option("option3", "Third Option");
    });

if response.changed {
    println!("Selected: {:?}", response.selected);
}

Implementations§

Source§

impl<'a> RadioGroup<'a>

Source

pub const fn new(selected_value: &'a mut Option<String>) -> Self

Create a new radio group

§Arguments
  • selected_value - Mutable reference to the currently selected value
Source

pub fn label(self, label: impl Into<String>) -> Self

Set a label for the group

Source

pub const fn disabled(self, disabled: bool) -> Self

Set disabled state for all radios in the group

Source

pub fn show<R>( self, ui: &mut Ui, content: impl FnOnce(&mut RadioGroupBuilder<'_>) -> R, ) -> RadioGroupResponse

Show the radio group with closure-based API

Auto Trait Implementations§

§

impl<'a> Freeze for RadioGroup<'a>

§

impl<'a> RefUnwindSafe for RadioGroup<'a>

§

impl<'a> Send for RadioGroup<'a>

§

impl<'a> Sync for RadioGroup<'a>

§

impl<'a> Unpin for RadioGroup<'a>

§

impl<'a> UnsafeUnpin for RadioGroup<'a>

§

impl<'a> !UnwindSafe for RadioGroup<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.