Browse Source

Fixed a bug causing duplicate TooltipWindows to be shown when multiple plug-in windows were open

tags/2021-05-28
ed 6 years ago
parent
commit
8de98f5a82
1 changed files with 38 additions and 35 deletions
  1. +38
    -35
      modules/juce_gui_basics/windows/juce_TooltipWindow.cpp

+ 38
- 35
modules/juce_gui_basics/windows/juce_TooltipWindow.cpp View File

@@ -156,50 +156,53 @@ void TooltipWindow::timerCallback()
auto* newComp = mouseSource.isTouch() ? nullptr : mouseSource.getComponentUnderMouse();
auto newTip = newComp != nullptr ? getTipFor (*newComp) : String();
bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse);
lastComponentUnderMouse = newComp;
lastTipUnderMouse = newTip;
if (newComp == nullptr || getParentComponent() == nullptr || newComp->getPeer() == getPeer())
{
auto newTip = newComp != nullptr ? getTipFor (*newComp) : String();
bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse);
lastComponentUnderMouse = newComp;
lastTipUnderMouse = newTip;
auto clickCount = desktop.getMouseButtonClickCounter();
auto wheelCount = desktop.getMouseWheelMoveCounter();
bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves);
mouseClicks = clickCount;
mouseWheelMoves = wheelCount;
auto clickCount = desktop.getMouseButtonClickCounter();
auto wheelCount = desktop.getMouseWheelMoveCounter();
bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves);
mouseClicks = clickCount;
mouseWheelMoves = wheelCount;
auto mousePos = mouseSource.getScreenPosition();
bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12;
lastMousePos = mousePos;
auto mousePos = mouseSource.getScreenPosition();
bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12;
lastMousePos = mousePos;
if (tipChanged || mouseWasClicked || mouseMovedQuickly)
lastCompChangeTime = now;
if (tipChanged || mouseWasClicked || mouseMovedQuickly)
lastCompChangeTime = now;
if (isVisible() || now < lastHideTime + 500)
{
// if a tip is currently visible (or has just disappeared), update to a new one
// immediately if needed..
if (newComp == nullptr || mouseWasClicked || newTip.isEmpty())
if (isVisible() || now < lastHideTime + 500)
{
if (isVisible())
// if a tip is currently visible (or has just disappeared), update to a new one
// immediately if needed..
if (newComp == nullptr || mouseWasClicked || newTip.isEmpty())
{
lastHideTime = now;
hideTip();
if (isVisible())
{
lastHideTime = now;
hideTip();
}
}
else if (tipChanged)
{
displayTip (mousePos.roundToInt(), newTip);
}
}
else if (tipChanged)
{
displayTip (mousePos.roundToInt(), newTip);
}
}
else
{
// 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)
else
{
displayTip (mousePos.roundToInt(), newTip);
// 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)
{
displayTip (mousePos.roundToInt(), newTip);
}
}
}
}


Loading…
Cancel
Save