Module zng::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§

Functions§

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