Struct RadioGroup

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

Group to coordinate multiple radio buttons.

A RadioGroup is used to create and manage RadioButtons.

A RadioGroup can be cloned; it will keep pointing to the same group.

Implementations§

Source§

impl<T> RadioGroup<T>
where T: 'static + Send + Sync,

Source

pub fn new() -> RadioGroup<T>

Creates an empty group for radio buttons.

Source

pub fn global<S>(key: S) -> RadioGroup<T>
where S: Into<String>,

Get a global group based on a key and T type.

Source

pub fn with_global<F, R, S>(key: S, f: F) -> R
where S: Into<String>, F: FnOnce(&mut RadioGroup<T>) -> R,

Run a closure on a radio group from a global pool.

If none exist with the given type T and key, a new one will be created.

Source

pub fn button<S>(&mut self, value: T, label: S) -> RadioButton<T>

Adds a new button to the group.

The button will display label next to it, and will embed value.

Source

pub fn selected_id(&self) -> usize

Returns the id of the selected button.

Buttons are indexed in the order they are created, starting from 0.

Source

pub fn selection(&self) -> Arc<T>

Returns the value associated with the selected button.

§Panics

If the group is empty (no button).

Source

pub fn set_on_change<F>(&mut self, on_change: F)
where F: 'static + Fn(&mut Cursive, &T) + Send + Sync,

Sets a callback to be used when the selection changes.

Source

pub fn on_change<F>(self, on_change: F) -> RadioGroup<T>
where F: 'static + Fn(&mut Cursive, &T) + Send + Sync,

Sets a callback to be used when the selection changes.

Chainable variant.

Source§

impl RadioGroup<String>

Source

pub fn button_str<S>(&mut self, text: S) -> RadioButton<String>
where S: Into<String>,

Adds a button, using the label itself as value.

Trait Implementations§

Source§

impl<T> Clone for RadioGroup<T>

Source§

fn clone(&self) -> RadioGroup<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Default for RadioGroup<T>
where T: 'static + Send + Sync,

Source§

fn default() -> RadioGroup<T>

Returns the “default value” for a type. Read more
Source§

impl Resolvable for RadioGroup<String>

Source§

fn from_config( config: &Value, context: &Context, ) -> Result<RadioGroup<String>, Error>

Build from a config (a JSON value). Read more
Source§

fn from_any(any: Box<dyn Any>) -> Option<Self>
where Self: Sized + Any,

Build from an Any variable. Read more

Auto Trait Implementations§

§

impl<T> Freeze for RadioGroup<T>

§

impl<T> RefUnwindSafe for RadioGroup<T>

§

impl<T> Send for RadioGroup<T>
where T: Sync + Send,

§

impl<T> Sync for RadioGroup<T>
where T: Sync + Send,

§

impl<T> Unpin for RadioGroup<T>

§

impl<T> UnwindSafe for RadioGroup<T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> With for T

Source§

fn wrap_with<U, F>(self, f: F) -> U
where F: FnOnce(Self) -> U,

Calls the given closure and return the result. Read more
Source§

fn with<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure on self.
Source§

fn try_with<E, F>(self, f: F) -> Result<Self, E>
where F: FnOnce(&mut Self) -> Result<(), E>,

Calls the given closure on self.
Source§

fn with_if<F>(self, condition: bool, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure if condition == true.