Flickering due to TooltipWindow appearing under the mouse cursor


#1

I am in a condition where my tooltips have a good chance of appearing right under the mouse cursor that triggered them.

When that happens, this sequence of events results in a flickering of the tooltip.

Lets suppose for this example that the tooltip client is a Button

  1. The mouse cursor hovers over the Button for the time required for the tooltip to appear

  2. the TooltipWindow appears as expected, under the mouse cursor

  3. a moment later, the timerCallback() in TooltipWindow ticks and detects that the component under the mouse is not the Button anymore, because now there is the TooltipWindow in the way

  4. The TooltipWindow itself is not a TooltipClient (rightly so) and thus the tooltip is made to disappear

  5. I have not moved the mouse cursor all this time, so now that the tooltip has disappeared, the component under the mouse is now once again my Button

  6. The Timer in TooltipWindow ticks again and shows the tooltip for my Button right under the mouse cursor. This replicates the condition of step #2 above, resulting in a loop that makes the tooltip flicker in and out of existence.

Please note that this happens in a project that was made with JUCE 3 and the problem didn’t exist with it.

I have tried to work around this problem by making the TooltipWindow not intercepting mouse clicks (setInterceptMouseClicks(false) ) which should prevent it from being detected as the component under the mouse.

Unfortunately, it seems that the getComponentUnderMouse() used in the tooltip timerCallback() ignores that flag.
In my opinion that is the wrong part: tooltips should take into account the actual hitTest() of Components rather than just their rectangular boundaries in the screen area. This applies not only to my case described here, but also for example to Components representing knobs, that have a round hitArea().

(I am on Mac, but due to the nature of the problem I suppose the same behavior happens on Windows)


#2

Adding the flag ComponentPeer::windowIgnoresMouseClicks to addToDesktop in juce_gui_basics/windows/juce_ToolTipWindow.cpp:93, so

addToDesktop (ComponentPeer::windowHasDropShadow
                    | ComponentPeer::windowIsTemporary
                    | ComponentPeer::windowIgnoresKeyPresses
                    | ComponentPeer::windowIgnoresMouseClicks);

Can you test if this works for you?


#3

This change works perfectly, thanks!
Will you include this in the JUCE codebase?


#4

Done! :slight_smile: (see the develop branch)