Add quick example to widget::button module

This commit is contained in:
Héctor Ramón Jiménez 2024-09-18 23:05:50 +02:00
parent dc2efb3fab
commit 0a95af78f4
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 48 additions and 14 deletions

View file

@ -653,7 +653,21 @@ where
/// Creates a new [`Button`] with the provided content.
///
/// [`Button`]: crate::Button
/// ```no_run
/// # mod iced { pub mod widget { pub use iced_widget::*; } }
/// # pub type State = ();
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
/// use iced::widget::button;
///
/// #[derive(Clone)]
/// enum Message {
/// ButtonPressed,
/// }
///
/// fn view(state: &State) -> Element<'_, Message> {
/// button("Press me!").on_press(Message::ButtonPressed).into()
/// }
/// ```
pub fn button<'a, Message, Theme, Renderer>(
content: impl Into<Element<'a, Message, Theme, Renderer>>,
) -> Button<'a, Message, Theme, Renderer>