1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

TooltipWindow: Avoid re-showing a tooltip if the mouse has not moved since it was last clicked

This behaviour more closely mirrors the behaviour of other applications.
This commit is contained in:
reuk 2021-08-23 19:58:03 +01:00
parent c802319241
commit 10a26b7584
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -191,6 +191,14 @@ void TooltipWindow::timerCallback()
if (tipChanged || mouseWasClicked || mouseMovedQuickly)
lastCompChangeTime = now;
auto showTip = [this, &mouseSource, &mousePos, &newTip]
{
bool mouseHasMovedSinceClick = mouseSource.getLastMouseDownPosition() != lastMousePos;
if (mouseHasMovedSinceClick)
displayTip (mousePos.roundToInt(), newTip);
};
if (isVisible() || now < lastHideTime + 500)
{
// if a tip is currently visible (or has just disappeared), update to a new one
@ -205,18 +213,17 @@ void TooltipWindow::timerCallback()
}
else if (tipChanged)
{
displayTip (mousePos.roundToInt(), newTip);
showTip();
}
}
else
{
// if there isn't currently a tip, but one is needed, only let it
// appear after a timeout..
// if there isn't currently a tip, but one is needed, only let it appear after a timeout
if (newTip.isNotEmpty()
&& newTip != tipShowing
&& now > lastCompChangeTime + (uint32) millisecondsBeforeTipAppears)
&& newTip != tipShowing
&& now > lastCompChangeTime + (uint32) millisecondsBeforeTipAppears)
{
displayTip (mousePos.roundToInt(), newTip);
showTip();
}
}
}