diff options
author | 2024-09-19 06:27:54 +0200 | |
---|---|---|
committer | 2024-09-19 06:27:54 +0200 | |
commit | 4e38992636dded5868e74e5630a5da72bb4e5f93 (patch) | |
tree | 6e71b5d8e8658506636125723ca410ea44ca9209 /widget/src/helpers.rs | |
parent | 22fbb9c2213892ae7981d5946b177a8846c4399e (diff) | |
download | iced-4e38992636dded5868e74e5630a5da72bb4e5f93.tar.gz iced-4e38992636dded5868e74e5630a5da72bb4e5f93.tar.bz2 iced-4e38992636dded5868e74e5630a5da72bb4e5f93.zip |
Show `tooltip` doc example in multiple places
Diffstat (limited to 'widget/src/helpers.rs')
-rw-r--r-- | widget/src/helpers.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index ec4f2265..817d437c 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -743,8 +743,29 @@ where /// Creates a new [`Tooltip`] for the provided content with the given /// [`Element`] and [`tooltip::Position`]. /// -/// [`Tooltip`]: crate::Tooltip -/// [`tooltip::Position`]: crate::tooltip::Position +/// Tooltips display a hint of information over some element when hovered. +/// +/// # Example +/// ```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::{container, tooltip}; +/// +/// enum Message { +/// // ... +/// } +/// +/// fn view(_state: &State) -> Element<'_, Message> { +/// tooltip( +/// "Hover me to display the tooltip!", +/// container("This is the tooltip contents!") +/// .padding(10) +/// .style(container::rounded_box), +/// tooltip::Position::Bottom, +/// ).into() +/// } +/// ``` pub fn tooltip<'a, Message, Theme, Renderer>( content: impl Into<Element<'a, Message, Theme, Renderer>>, tooltip: impl Into<Element<'a, Message, Theme, Renderer>>, |