mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-02 03:20:06 +00:00
Reverted 876aaf4 which was causing TooltipWindows constructed with a parent component not in their parent hierarchy to not be displayed
This commit is contained in:
parent
3687710c58
commit
6f52fc5758
1 changed files with 41 additions and 43 deletions
|
|
@ -103,9 +103,11 @@ void TooltipWindow::displayTip (Point<int> screenPos, const String& tip)
|
|||
#if JUCE_DEBUG
|
||||
activeTooltipWindows.addIfNotAlreadyThere (this);
|
||||
|
||||
auto* parent = getParentComponent();
|
||||
|
||||
for (auto* w : activeTooltipWindows)
|
||||
{
|
||||
if (w != this && w->tipShowing == tipShowing)
|
||||
if (w != this && w->tipShowing == tipShowing && w->getParentComponent() == parent)
|
||||
{
|
||||
// Looks like you have more than one TooltipWindow showing the same tip..
|
||||
// Be careful not to create more than one instance of this class with the
|
||||
|
|
@ -153,55 +155,51 @@ void TooltipWindow::timerCallback()
|
|||
auto now = Time::getApproximateMillisecondCounter();
|
||||
|
||||
auto* newComp = mouseSource.isTouch() ? nullptr : mouseSource.getComponentUnderMouse();
|
||||
auto* parent = getParentComponent();
|
||||
|
||||
if (newComp == nullptr || parent == nullptr || parent == newComp || parent->isParentOf (newComp))
|
||||
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 mousePos = mouseSource.getScreenPosition();
|
||||
bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12;
|
||||
lastMousePos = mousePos;
|
||||
|
||||
if (tipChanged || mouseWasClicked || mouseMovedQuickly)
|
||||
lastCompChangeTime = now;
|
||||
|
||||
if (isVisible() || now < lastHideTime + 500)
|
||||
{
|
||||
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 mousePos = mouseSource.getScreenPosition();
|
||||
bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12;
|
||||
lastMousePos = mousePos;
|
||||
|
||||
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 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())
|
||||
{
|
||||
if (isVisible())
|
||||
{
|
||||
lastHideTime = now;
|
||||
hideTip();
|
||||
}
|
||||
}
|
||||
else if (tipChanged)
|
||||
{
|
||||
displayTip (mousePos.roundToInt(), newTip);
|
||||
lastHideTime = now;
|
||||
hideTip();
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (tipChanged)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
displayTip (mousePos.roundToInt(), newTip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue