zng/tip.rs
1#![cfg(feature = "tooltip")]
2
3//! Tooltip properties and widget.
4//!
5//! The [`tooltip`](fn@tooltip) and [`tooltip_fn`](fn@tooltip_fn) properties can be set on any widget to git it a tooltip.
6//! The tooltip itself can also be any widget, but the [`Tip!`](struct@Tip) widget is recommended. You can also set a tooltip
7//! that only appears when the widget is disabled using [`disabled_tooltip`](fn@disabled_tooltip).
8//!
9//! The example below declares a button that toggles enabled showing different tooltips depending on the state.
10//!
11//! ```
12//! use zng::prelude::*;
13//! # let _app = APP.defaults();
14//!
15//! let enabled = var(true);
16//! # let _ =
17//! Button! {
18//! tip::tooltip = Tip!(Text!("enabled tooltip"));
19//! tip::disabled_tooltip = Tip!(Text!("disabled tooltip"));
20//!
21//! on_click = hn!(enabled, |_| enabled.set(false));
22//! gesture::on_disabled_click = hn!(enabled, |_| enabled.set(true));
23//! child = Text!(enabled.map(|&e| formatx!("enabled = {e}")));
24//! widget::enabled;
25//! }
26//! # ;
27//! ```
28//!
29//! # Full API
30//!
31//! See [`zng_wgt_tooltip`] for the full tooltip API.
32
33pub use zng_wgt_tooltip::{
34 DefaultStyle, Tip, TooltipArgs, access_tooltip_anchor, access_tooltip_duration, disabled_tooltip, disabled_tooltip_fn, style_fn,
35 tooltip, tooltip_anchor, tooltip_context_capture, tooltip_delay, tooltip_duration, tooltip_fn, tooltip_interval,
36};