No button tooltips in JUCE Widgets Demo

In the code, I see tooltips being specified for each button. But when I build and run the demo, I see no tooltips at all. Is there something that needs to be done to make them appear, or should they just show up when you hold the mouse over a button?

Every Component is a TooltipClient, i.e. something that wants to display a tooltip. Since there should ever be only one tooltip showing at a time, there is a TooltipWindow, that will be called to display the tooltip defined in the TooltipClient.
The documentation of TooltipWindow explains best, how to create one. It is basically a singleton so it can be reached by all components.

The TooltipWindow object will then stay invisible, waiting until the mouse hovers for the specified length of time - it will then see if it’s currently over a component which implements the TooltipClient interface, and if so, it will make itself visible to show the tooltip in the appropriate place.

Hope that helps

1 Like

Thanks. But what I’m saying is that the code for the Widgets demo, i.e. the buttons page, shows tooltips in the code.

            auto db = addToList (new DrawableButton ("Button 4", DrawableButton::ImageOnButtonBackground));
            db->setImages (&normal, &over, &down);
            db->setClickingTogglesState (true);
            db->setColour (DrawableButton::backgroundColourId,   Colours::white);
            db->setColour (DrawableButton::backgroundOnColourId, Colours::yellow);
            db->setBounds (400, 150, 50, 50);
            db->setTooltip ("This is a DrawableButton on a standard button background");
            db->onClick = popupMessageCallback;

But hovering the mouse over any of these buttons never shows a tooltip. The code implies the existence of tooltips, but I don’t see them. I’m looking for an example of how to implement.

Make sure you have a line similar to below at a broadly available point in your code. In the case of plugins, I place it in PluginEditor.h.

TooltipWindow tooltipWindow{ this }; // instance required for ToolTips to work

Perhaps that will help.

1 Like

I checked, it is indeed missing in the examples/DemoRunner.

Like @bwall said, it is sufficient to have an instance laying around. The docs suggest to use a SharedResourcePointer, since that is conveniently created, if none is available, and disposed afterwards. If you have SharedResourcePointer instances in different places, that is no problem, it is like the name suggests, shared.

In an app you can add this as a member where ever you want, MainComponent is a good place.
For the demo, I added this line in ButtonsPage under private:

SharedResourcePointer<TooltipWindow> tooltipWindow;

That makes the tooltip appear.

Thanks! It now works. I wonder if someone can fix the Demo Examples?