summaryrefslogtreecommitdiffstats
path: root/widget/src/tooltip.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-09-19 06:59:05 +0200
committerLibravatar GitHub <noreply@github.com>2024-09-19 06:59:05 +0200
commitddbb8445bf60de7169727721a5cb57048ded3d82 (patch)
tree1f2b90d5f0e010be72e4bbd20da6c22e1478b573 /widget/src/tooltip.rs
parent1f8dc1f3dda25c699b94c653d5d569f4142e9b83 (diff)
parent31c42c1d02d6a76dedaa780e6832a23765c8aef2 (diff)
downloadiced-ddbb8445bf60de7169727721a5cb57048ded3d82.tar.gz
iced-ddbb8445bf60de7169727721a5cb57048ded3d82.tar.bz2
iced-ddbb8445bf60de7169727721a5cb57048ded3d82.zip
Merge pull request #2587 from iced-rs/improve-api-reference
Add widget examples to API reference and update `README`
Diffstat (limited to 'widget/src/tooltip.rs')
-rw-r--r--widget/src/tooltip.rs46
1 files changed, 45 insertions, 1 deletions
diff --git a/widget/src/tooltip.rs b/widget/src/tooltip.rs
index 39f2e07d..e98f4da7 100644
--- a/widget/src/tooltip.rs
+++ b/widget/src/tooltip.rs
@@ -1,4 +1,26 @@
-//! Display a widget over another.
+//! 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()
+//! }
+//! ```
use crate::container;
use crate::core::event::{self, Event};
use crate::core::layout::{self, Layout};
@@ -13,6 +35,28 @@ use crate::core::{
};
/// An element to display a widget over another.
+///
+/// # 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()
+/// }
+/// ```
#[allow(missing_debug_implementations)]
pub struct Tooltip<
'a,