summaryrefslogtreecommitdiffstats
path: root/native/src/widget/radio.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-04-12 06:43:58 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-04-12 06:43:58 +0200
commitb505b7203563b8a75a65451f47a3386c50864e6d (patch)
tree28a65baa0ca11927c39300e2b4a4ebb986a4699a /native/src/widget/radio.rs
parent4fdd76c07c15f85a518c240aca0e55f482b18bc3 (diff)
downloadiced-b505b7203563b8a75a65451f47a3386c50864e6d.tar.gz
iced-b505b7203563b8a75a65451f47a3386c50864e6d.tar.bz2
iced-b505b7203563b8a75a65451f47a3386c50864e6d.zip
Move `radio` example to `Radio` docs
Diffstat (limited to '')
-rw-r--r--native/src/widget/radio.rs37
1 files changed, 32 insertions, 5 deletions
diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs
index 9daddfbc..3ca041bf 100644
--- a/native/src/widget/radio.rs
+++ b/native/src/widget/radio.rs
@@ -21,10 +21,13 @@ pub use iced_style::radio::{Appearance, StyleSheet};
/// # type Radio<Message> =
/// # iced_native::widget::Radio<Message, iced_native::renderer::Null>;
/// #
+/// # use iced_native::column;
/// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// pub enum Choice {
/// A,
/// B,
+/// C,
+/// All,
/// }
///
/// #[derive(Debug, Clone, Copy)]
@@ -34,12 +37,36 @@ pub use iced_style::radio::{Appearance, StyleSheet};
///
/// 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
+/// );
///
-/// ![Radio buttons drawn by `iced_wgpu`](https://github.com/iced-rs/iced/blob/7760618fb112074bc40b148944521f312152012a/docs/images/radio.png?raw=true)
+/// let content = column![a, b, c, all];
+/// ```
#[allow(missing_debug_implementations)]
pub struct Radio<Message, Renderer>
where
@@ -78,8 +105,8 @@ where
/// * 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 new<F, V>(
- value: V,
label: impl Into<String>,
+ value: V,
selected: Option<V>,
f: F,
) -> Self