Tooltip displayed by TooltipWindow's displayTip hides immediately

The tooltip displayed by calling TooltipWindow’s displayTip method is hidden immediately after showing it. I can see the tooltip correctly for a split second right after calling displayTip. I’m calling the method from a mouseUp event handler. What is wrong here? Shouldn’t the tooltip show normally before it’s hidden?

Thanks for reporting. I’ve fixed a few issues with tooltips on the develop branch:

Can you try with these commits and see if they fix the issue you are seeing?

Thanks @ed95 Tried the development branch. The behaviour is the same. I’m testing on macOS and showing from mouseUp handler of the MainComponent - if that means anything to you. Here’s the call stack at the immediate hideTip.

Can you post some minimal example code which reproduces the problem?

This change broke tooltips for me. I have a button to enable tooltips, and

juce::String TooltipWindow::getTipFor (Component& c)
{   // juce::Button on
    return on.getToggleState() ? juce::TooltipWindow::getTipFor (c) : juce::String();

If tooltips are disabled and I reenable them, they’re not shown. Only if the program is started with tooltips enabled I can see them.

(edit) Possible fix:

void TooltipWindow::mouseDown (const MouseEvent&)
    if (isVisible())
        dismissalMouseEventOccured = true;

void TooltipWindow::mouseWheelMove (const MouseEvent&, const MouseWheelDetails&)
    if (isVisible())
        dismissalMouseEventOccured = true;

Thanks for reporting and thanks for the fix! It looks like the right thing to do, I’ll push something to develop shortly.

1 Like
1 Like

Sure, here you go (5.6 KB)

Looks to me 100% reproducible in any setting.

Thanks for the example code. Can you see if applying the attached patch fixes the issue for you?

01.patch (5.3 KB)

Yes, with the above patch, the tooltip remains on screen. Its certainly usable now!

There’s some of its behaviour i find a bit unexpected

  1. the tooltip has no timer i.e. it shows indefinitely until
    a) mouse is pressed inside the window or
    b) moved outside the app window (or onto the tooltip itself - which effectively is the same thing i guess) or
    c) hideTip is called.
  2. displayTooltip takes screen coordinates instead of the parent window’s

I assume this behaviour is by design.

Thanks @ed95 !

Yes, this is intentional behaviour. To show a tooltip for a specific component you should use the SettableTooltipClient interface which most JUCE widgets implement. The displayTip() method should only be used to manually force a tooltip to show on the desktop for some reason, hence why it takes a position in screen coordinates and will remain visible until hideTip() is called or a dismissal mouse event occurs.

Yes, i’m using the SettableTooltipClient successfully. It’s very easy to use. I totally understand that the displayTip interface exists only for special cases. Good to have it!

This is on develop now:

1 Like