Why setTooltip doesn't work?

In extra/example projects, I just write one line code in MainComponent contructor:

quitButton->setTooltip(L"this is a quti button");

But when the mouse on the quit button,the tool tip doeesn’t work.

I also read extra/JuceDemo souce code,setTooltip work in JuceDemo, I don’t know why,what’s the difference between the two projects.

Did you create a TooltipWindow instance?


How to create TooltipWindow instance?
Is system to create the window automatically?

A window that displays a pop-up tooltip when the mouse hovers over another component.

To enable tooltips in your app, just create a single instance of a TooltipWindow

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.

@see TooltipClient, SettableTooltipClient

class JUCE_API TooltipWindow : public Component,
private Timer

I write code below in main window contructor:

addAndMakeVisible(_tooltipWindow = new TooltipWindow());

but to my strange, the ToolbarButton’s tool tip doesn’t display until I click the button.

1 Like

Don’t: use 'new’
Don’t: add it to your main window
Don’t: put ‘L’ in front of your string literals (irrelevant to your problem, but it’s bad style)

Do: search the demo app for “TooltipWindow” and look at how it’s done

The demo app must have changed since 2012. As far as I can see, there is no longer any “TooltipWindow” text, in any source file in the “examples/demorunner” folder.

So for anyone needing help, simply declare like below. Two options, first for just default settings, and second to specify parameters.

How to setup “ToolTip”:


TooltipWindow tooltipWindow;


TooltipWindow tooltipWindow { this, 500 };