Why setTooltip doesn't work?


#1

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.
Thanks.


#2

Did you create a TooltipWindow instance?

Chris


#3

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


#4

[code]/**
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
object.

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
{
public:[/code]


#5

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.


#6

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