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
The mouse cursor hovers over the
Buttonfor the time required for the tooltip to appear
TooltipWindowappears as expected, under the mouse cursor
a moment later, the
TooltipWindowticks and detects that the component under the mouse is not the
Buttonanymore, because now there is the
TooltipWindowin the way
TooltipWindowitself is not a
TooltipClient(rightly so) and thus the tooltip is made to disappear
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
TooltipWindowticks 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)