Module tip

Module tip 

Source
Expand description

Tooltip properties and widget.

The tooltip and tooltip_fn properties can be set on any widget to git it a tooltip. The tooltip itself can also be any widget, but the Tip! widget is recommended. You can also set a tooltip that only appears when the widget is disabled using disabled_tooltip.

The example below declares a button that toggles enabled showing different tooltips depending on the state.

use zng::prelude::*;

let enabled = var(true);
Button! {
    tip::tooltip = Tip!(Text!("enabled tooltip"));
    tip::disabled_tooltip = Tip!(Text!("disabled tooltip"));

    on_click = hn!(enabled, |_| enabled.set(false));
    gesture::on_disabled_click = hn!(enabled, |_| enabled.set(true));
    child = Text!(enabled.map(|&e| formatx!("enabled = {e}")));
    widget::enabled;
}

§Full API

See zng_wgt_tooltip for the full tooltip API.

Structs§

DefaultStyle
W Tip default style.
Tip
W A tooltip popup.
TooltipArgs
Arguments for tooltip widget functions.

Functions§

access_tooltip_anchor
P Set the position of the tip widgets opened for the widget or its descendants without cursor interaction.
access_tooltip_duration
P Sets the maximum duration a tooltip stays open on the widget or descendants when it is opened without cursor interaction.
disabled_tooltip
P Disabled widget tooltip.
disabled_tooltip_fn
P Disabled widget tooltip.
style_fn
P Extends or replaces the widget style.
tooltip
P Widget tooltip.
tooltip_anchor
P Set the position of the tip widgets opened for the widget or its descendants.
tooltip_context_capture
P Defines if the tooltip captures the build/instantiate context and sets it in the node context.
tooltip_delay
P Set the duration the cursor must be over the widget or its descendants before the tip widget is opened.
tooltip_duration
P Sets the maximum duration a tooltip stays open on the widget or descendants.
tooltip_fn
P Widget tooltip set as a widget function that is called every time the tooltip must be shown.
tooltip_interval
P Sets the maximum interval a second tooltip is opened instantly if a previous tip was just closed.