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:
parent
c802319241
commit
10a26b7584
1 changed files with 13 additions and 6 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue