[][src]Struct iced::widget::radio::Radio

pub struct Radio<Color, Message> { /* fields omitted */ }

A circular button representing a choice, with a generic text Color.

It implements Widget when the associated Renderer implements the radio::Renderer trait.

Example

use iced::{Column, Radio};

#[derive(Debug, Clone, Copy)]
pub enum Color {
    Black,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Choice {
    A,
    B,
}

#[derive(Debug, Clone, Copy)]
pub enum Message {
    RadioSelected(Choice),
}

let selected_choice = Some(Choice::A);

Radio::new(Choice::A, "This is A", selected_choice, Message::RadioSelected)
    .label_color(Color::Black);

Radio::new(Choice::B, "This is B", selected_choice, Message::RadioSelected)
    .label_color(Color::Black);

Radio buttons drawn by Coffee's renderer

Methods

impl<Color, Message> Radio<Color, Message>[src]

pub fn new<F, V>(value: V, label: &str, selected: Option<V>, f: F) -> Self where
    V: Eq + Copy,
    F: 'static + Fn(V) -> Message, 
[src]

Creates a new Radio button.

It expects:

  • the value related to the Radio button
  • the label of the Radio button
  • the current selected value
  • a function that will be called when the Radio is selected. It receives the value of the radio and must produce a Message.

pub fn label_color(self, color: Color) -> Self[src]

Sets the Color of the label of the Radio.

Trait Implementations

impl<Color, Message, Renderer> Widget<Message, Renderer> for Radio<Color, Message> where
    Color: 'static + Copy + Debug,
    Renderer: Renderer + Renderer<Color>,
    Message: Copy + Debug
[src]

impl<'a, Color, Message, Renderer> From<Radio<Color, Message>> for Element<'a, Message, Renderer> where
    Color: 'static + Copy + Debug,
    Renderer: Renderer + Renderer<Color>,
    Message: 'static + Copy + Debug
[src]

impl<Color, Message> Debug for Radio<Color, Message> where
    Color: Debug,
    Message: Debug
[src]

Auto Trait Implementations

impl<Color, Message> Sync for Radio<Color, Message> where
    Color: Sync,
    Message: Sync

impl<Color, Message> Send for Radio<Color, Message> where
    Color: Send,
    Message: Send

impl<Color, Message> Unpin for Radio<Color, Message> where
    Color: Unpin,
    Message: Unpin

impl<Color, Message> UnwindSafe for Radio<Color, Message> where
    Color: UnwindSafe,
    Message: UnwindSafe

impl<Color, Message> RefUnwindSafe for Radio<Color, Message> where
    Color: RefUnwindSafe,
    Message: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,