How to use tooltips

I can’t get the ToolTip to work. I added it as a child to an existing sprite, and I also added a new sprite to the ToolTip (so that it shows the new sprite when hovering over the existing sprite). But when I hover over the (parent) sprite, nothing ever happens.

Are you setting a height/width set on the tooltip?

Here is how the editor creates tooltips:

UIElement@ CreateToolTip(UIElement@ parent, const String&in title, const IntVector2&in offset)
    ToolTip@ toolTip = parent.CreateChild("ToolTip");
    toolTip.position = offset;

    BorderImage@ textHolder = toolTip.CreateChild("BorderImage");

    Text@ toolTipText = textHolder.CreateChild("Text");
    toolTipText.text = title;

    return toolTip;

Here are those styles

    <element type="ToolTipBorderImage" style="BorderImage">
        <attribute name="Layout Mode" value="Horizontal" />
        <attribute name="Layout Border" value="6 2 6 2" />
        <attribute name="Image Rect" value="48 0 64 16" />
        <attribute name="Border" value="6 2 2 2" />
    <element type="ToolTipText" style="Text">
        <attribute name="Font" value="Font;Fonts/BlueHighway.ttf" />
        <attribute name="Font Size" value="12" />

The tooltip in the editor automatically calculates its height/width from the “Layout Mode”

Thanks. But I’ve now tried about a dozen things, and I still can’t see my ToolTip. I’m using C++, by the way. I’m also not sure if I’m supposed to call the ToolTip’s public Update function? Either way, it still doesn’t work.

Maybe someone could post a minimal code example in C++ that works?

I’ll send a pull request tomorrow, adding drag and tooltip to sample#02 HellloGUI.

I just took a look at it, thanks. So it turns out ToolTips only work with buttons. That’s good to know.

Tooltips should work with any element that has input enabled, so that they recognize being hovered on. Sprites and bare UIElements are assumed to be passive decoration by default, so you’ll need to enable input by calling SetEnabled(true) on them.

Ah, that makes sense!