commit
e7549877ef
2 changed files with 33 additions and 6 deletions
|
|
@ -147,7 +147,7 @@ where
|
||||||
Renderer::Theme: widget::radio::StyleSheet,
|
Renderer::Theme: widget::radio::StyleSheet,
|
||||||
V: Copy + Eq,
|
V: Copy + Eq,
|
||||||
{
|
{
|
||||||
widget::Radio::new(value, label, selected, on_click)
|
widget::Radio::new(label, value, selected, on_click)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new [`Toggler`].
|
/// Creates a new [`Toggler`].
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,13 @@ pub use iced_style::radio::{Appearance, StyleSheet};
|
||||||
/// # type Radio<Message> =
|
/// # type Radio<Message> =
|
||||||
/// # iced_native::widget::Radio<Message, iced_native::renderer::Null>;
|
/// # iced_native::widget::Radio<Message, iced_native::renderer::Null>;
|
||||||
/// #
|
/// #
|
||||||
|
/// # use iced_native::column;
|
||||||
/// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
/// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
/// pub enum Choice {
|
/// pub enum Choice {
|
||||||
/// A,
|
/// A,
|
||||||
/// B,
|
/// B,
|
||||||
|
/// C,
|
||||||
|
/// All,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// #[derive(Debug, Clone, Copy)]
|
/// #[derive(Debug, Clone, Copy)]
|
||||||
|
|
@ -34,12 +37,36 @@ pub use iced_style::radio::{Appearance, StyleSheet};
|
||||||
///
|
///
|
||||||
/// let selected_choice = Some(Choice::A);
|
/// let selected_choice = Some(Choice::A);
|
||||||
///
|
///
|
||||||
/// Radio::new(Choice::A, "This is A", selected_choice, Message::RadioSelected);
|
/// let a = Radio::new(
|
||||||
|
/// "A",
|
||||||
|
/// Choice::A,
|
||||||
|
/// selected_choice,
|
||||||
|
/// Message::RadioSelected,
|
||||||
|
/// );
|
||||||
///
|
///
|
||||||
/// Radio::new(Choice::B, "This is B", selected_choice, Message::RadioSelected);
|
/// let b = Radio::new(
|
||||||
|
/// "B",
|
||||||
|
/// Choice::B,
|
||||||
|
/// selected_choice,
|
||||||
|
/// Message::RadioSelected,
|
||||||
|
/// );
|
||||||
|
///
|
||||||
|
/// let c = Radio::new(
|
||||||
|
/// "C",
|
||||||
|
/// Choice::C,
|
||||||
|
/// selected_choice,
|
||||||
|
/// Message::RadioSelected,
|
||||||
|
/// );
|
||||||
|
///
|
||||||
|
/// let all = Radio::new(
|
||||||
|
/// "All of the above",
|
||||||
|
/// Choice::All,
|
||||||
|
/// selected_choice,
|
||||||
|
/// Message::RadioSelected
|
||||||
|
/// );
|
||||||
|
///
|
||||||
|
/// let content = column![a, b, c, all];
|
||||||
/// ```
|
/// ```
|
||||||
///
|
|
||||||
/// 
|
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Radio<Message, Renderer>
|
pub struct Radio<Message, Renderer>
|
||||||
where
|
where
|
||||||
|
|
@ -78,8 +105,8 @@ where
|
||||||
/// * a function that will be called when the [`Radio`] is selected. It
|
/// * a function that will be called when the [`Radio`] is selected. It
|
||||||
/// receives the value of the radio and must produce a `Message`.
|
/// receives the value of the radio and must produce a `Message`.
|
||||||
pub fn new<F, V>(
|
pub fn new<F, V>(
|
||||||
value: V,
|
|
||||||
label: impl Into<String>,
|
label: impl Into<String>,
|
||||||
|
value: V,
|
||||||
selected: Option<V>,
|
selected: Option<V>,
|
||||||
f: F,
|
f: F,
|
||||||
) -> Self
|
) -> Self
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue