mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-21 01:24:21 +00:00
Added an assertion to catch people using more than one TooltipWindow, which seems to be a common mistake
This commit is contained in:
parent
737c82fcfc
commit
a1b9900bae
1 changed files with 17 additions and 0 deletions
|
|
@ -67,6 +67,10 @@ void TooltipWindow::updatePosition (const String& tip, Point<int> pos, Rectangle
|
|||
setVisible (true);
|
||||
}
|
||||
|
||||
#if JUCE_DEBUG
|
||||
static Array<TooltipWindow*> activeTooltipWindows;
|
||||
#endif
|
||||
|
||||
void TooltipWindow::displayTip (Point<int> screenPos, const String& tip)
|
||||
{
|
||||
jassert (tip.isNotEmpty());
|
||||
|
|
@ -97,6 +101,15 @@ void TooltipWindow::displayTip (Point<int> screenPos, const String& tip)
|
|||
| ComponentPeer::windowIgnoresMouseClicks);
|
||||
}
|
||||
|
||||
#if JUCE_DEBUG
|
||||
activeTooltipWindows.addIfNotAlreadyThere (this);
|
||||
|
||||
for (auto* w : activeTooltipWindows)
|
||||
if (w != this && w->tipShowing == tipShowing)
|
||||
jassertfalse; // Looks like you have more than one TooltipWindow showing the same tip.
|
||||
// Be careful not to create more than one instance of this class!
|
||||
#endif
|
||||
|
||||
toFront (false);
|
||||
}
|
||||
}
|
||||
|
|
@ -121,6 +134,10 @@ void TooltipWindow::hideTip()
|
|||
tipShowing.clear();
|
||||
removeFromDesktop();
|
||||
setVisible (false);
|
||||
|
||||
#if JUCE_DEBUG
|
||||
activeTooltipWindows.removeAllInstancesOf (this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue