pub struct Tooltip {
    pub handle: ControlHandle,
}
Expand description

Tooltips appear automatically, or pop up, when the user pauses the mouse pointer over a tool or some other UI element. The tooltip appears near the pointer and disappears when the user clicks a mouse button, moves the pointer away from the tool, or simply waits for a few seconds.

A tooltip can be applied to multiple controls, each with their own custom text. This is done/undone using the register/unregister functions. So do not think as Tooltip as a standalone toolip, but more like a manager.

A tooltip can support static text using register and dynamic text using register_callback.

Tooltip requires the tooltip features

Example:

use native_windows_gui as nwg;

/// Building a tooltip and add tooltips at the same time
fn build_tooltip(tt: &mut nwg::Tooltip, btn1: &nwg::Button, btn2: &nwg::Button) {
    nwg::Tooltip::builder()
        .register(btn1, "A test button")
        .register_callback(btn2)
        .build(tt);
}

/// Adding/Updating a tooltip after the initial tooltip creation
fn add_tooltip(btn: &nwg::Button, tt: &nwg::Tooltip) {
    tt.register(btn, "This is a button!");
}

/// Dynamic tooltip callback setup
fn add_dynamic_tooltip(tt: &nwg::Tooltip, btn: &nwg::Button) {
    tt.register_callback(btn);
}


struct GuiStruct {
    // Skipping other members
    tt: nwg::Tooltip,
    button: nwg::Button
}

impl GuiStruct {
    /// The dynamic tooltip callback, triggered by the event loop
    fn events_callback(&self, evt: nwg::Event, evt_data: &nwg::EventData, handle: nwg::ControlHandle) {
        match evt {
            nwg::Event::OnTooltipText => {
                // Compare the handle to check which control will display the tooltip
                if &handle == &self.button {
                    let tooltip_data = evt_data.on_tooltip_text();
                    tooltip_data.set_text(&format!("Button text: \"{}\"", self.button.text()));
                }
            },
            _ => {}
        }
    }
}


Fields

handle: ControlHandle

Implementations

Return the current text of the tooltip. There is no way to know the size of the text so you have to pass the buffer size. The default buffer size is 200 characters.

Change the text of a previously registered control Use the register function is associate a control with this tooltip

Set the icon and the title of a tooltip. This method use custom icon defined by user resources

Set the icon and the title of a tooltip. This method use built-in icon defined by TooltipIcon

Hide the tooltip popup

Return the number of controls registered by the tooltip

Set the delay time for the tooltip to spawn in milliseconds Set the value to None to reset the value to default

Return the delay time of the tooltip in milliseconds

Enable or disable the control Windows does not support reading the enabled state of a tooltip btw.

Register the tooltip under a control. owner must be a window control.

Register the tooltip under a control. owner must be a window control. When the user trigger the tooltip, the application receives a OnTooltipText event

Remove the tooltip from a control

Winapi class name used during control creation

Winapi base flags used during window creation

Winapi flags required by the control

Trait Implementations

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.