1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-04 03:40:07 +00:00

Added an 'includeChildren' parameter to Component::isMouseOverOrDragging

This commit is contained in:
jules 2016-01-28 17:08:15 +00:00
parent 082b15969f
commit 92bb5e8b74
2 changed files with 7 additions and 3 deletions

View file

@ -2969,14 +2969,18 @@ bool Component::isMouseButtonDown() const
return false;
}
bool Component::isMouseOverOrDragging() const
bool Component::isMouseOverOrDragging (const bool includeChildren) const
{
const Array<MouseInputSource>& mouseSources = Desktop::getInstance().getMouseSources();
for (MouseInputSource* mi = mouseSources.begin(), * const e = mouseSources.end(); mi != e; ++mi)
if (mi->getComponentUnderMouse() == this
{
Component* const c = mi->getComponentUnderMouse();
if ((c == this || (includeChildren && isParentOf (c)))
&& (mi->isMouse() || mi->isDragging()))
return true;
}
return false;
}

View file

@ -1768,7 +1768,7 @@ public:
This is a handy equivalent to (isMouseOver() || isMouseButtonDown()).
@see isMouseOver, isMouseButtonDown, isMouseButtonDownAnywhere
*/
bool isMouseOverOrDragging() const;
bool isMouseOverOrDragging (bool includeChildren = false) const;
/** Returns true if a mouse button is currently down.