I’m trying to give my custom components a tooltip, but can’t work it out. (The standard JUCE components work fine.)
Here’s what im doing:
what am I missing?
I will award you bonus points for telling me how to change the font size in the tooltip without rewriting the entire
I went in your trap. The
TextLayout layoutTooltipText() is a static method, so I see no way changing that without rewriting the polymorphic
const Colour baseColour (buttonColour.withMultipliedSaturation (sat));
if (shouldDrawButtonAsDown) return baseColour.contrasting (0.2f);
if (shouldDrawButtonAsHighlighted) return baseColour.contrasting (0.1f);
static TextLayout layoutTooltipText (const String& text, Colour colour) noexcept
const float tooltipFontSize = 13.0f;
const int maxToolTipWidth = 400;
s.append (text, Font (tooltipFontSize, Font::bold), colour);
tl.createLayoutWithBalancedLineLengths (s, (float) maxToolTipWidth);
About the not showing up, any chance, you disabled the
setInterceptMouseClicks() on your component or one of it’s parents? It blocks hitTest and therefore mouseEnter and mouseExit as well…
Just a shot in the dark…
Ok I got it. The problem was that my custom components had child components themselves, which were screen filling. And the tooltip only shows for the uppermost component.
(Kinda obvious in hindsight ^^)
another tip for folks getting to this discussion looking for an answer is the
SettableTooltipClient should be public / accessible.
Also of course you must have the TooltipWindow -
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.