Update disabled example of `Button` in docs
This commit is contained in:
parent
e66120b9c1
commit
d46dd67a91
|
@ -30,7 +30,8 @@ use std::hash::Hash;
|
||||||
/// .on_press(Message::ButtonPressed);
|
/// .on_press(Message::ButtonPressed);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Buttons can be disabled by not having an on_press.
|
/// If a [`Button::on_press`] handler is not set, the resulting [`Button`] will
|
||||||
|
/// be disabled:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use iced_native::{button, Text};
|
/// # use iced_native::{button, Text};
|
||||||
|
@ -38,13 +39,18 @@ use std::hash::Hash;
|
||||||
/// # type Button<'a, Message> =
|
/// # type Button<'a, Message> =
|
||||||
/// # iced_native::Button<'a, Message, iced_native::renderer::Null>;
|
/// # iced_native::Button<'a, Message, iced_native::renderer::Null>;
|
||||||
/// #
|
/// #
|
||||||
/// # #[derive(Clone)]
|
/// #[derive(Clone)]
|
||||||
/// # enum Message {
|
/// enum Message {
|
||||||
/// # ButtonPressed,
|
/// ButtonPressed,
|
||||||
/// # }
|
/// }
|
||||||
/// #
|
///
|
||||||
/// let mut state = button::State::new();
|
/// fn disabled_button(state: &mut button::State) -> Button<'_, Message> {
|
||||||
/// let disabled_button = Button::<Message>::new(&mut state, Text::new("I'm disabled!"));
|
/// Button::new(state, Text::new("I'm disabled!"))
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn enabled_button(state: &mut button::State) -> Button<'_, Message> {
|
||||||
|
/// disabled_button(state).on_press(Message::ButtonPressed)
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Button<'a, Message, Renderer: self::Renderer> {
|
pub struct Button<'a, Message, Renderer: self::Renderer> {
|
||||||
|
|
|
@ -21,19 +21,25 @@ use dodrio::bumpalo;
|
||||||
/// .on_press(Message::ButtonPressed);
|
/// .on_press(Message::ButtonPressed);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Buttons can be disabled by not having an on_press.
|
/// If a [`Button::on_press`] handler is not set, the resulting [`Button`] will
|
||||||
|
/// be disabled:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use iced_web::{button, Button, Text};
|
/// # use iced_web::{button, Button, Text};
|
||||||
/// #
|
/// #
|
||||||
/// # enum Message {
|
/// #[derive(Clone)]
|
||||||
/// # ButtonPressed,
|
/// enum Message {
|
||||||
/// # }
|
/// ButtonPressed,
|
||||||
/// #
|
/// }
|
||||||
/// let mut state = button::State::new();
|
///
|
||||||
/// let disabled_button = Button::<Message>::new(&mut state, Text::new("I'm disabled!"));
|
/// fn disabled_button(state: &mut button::State) -> Button<'_, Message> {
|
||||||
|
/// Button::new(state, Text::new("I'm disabled!"))
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn enabled_button(state: &mut button::State) -> Button<'_, Message> {
|
||||||
|
/// disabled_button(state).on_press(Message::ButtonPressed)
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Button<'a, Message> {
|
pub struct Button<'a, Message> {
|
||||||
content: Element<'a, Message>,
|
content: Element<'a, Message>,
|
||||||
|
|
Loading…
Reference in New Issue