mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a parameter includeChildren to Component::isMouseButtonDown
This commit is contained in:
parent
49ddaddbae
commit
7909af4ecb
2 changed files with 23 additions and 18 deletions
|
|
@ -325,7 +325,7 @@ struct Component::ComponentHelpers
|
|||
}
|
||||
|
||||
template <typename PointOrRect>
|
||||
static PointOrRect convertFromDistantParentSpace (const Component* parent, const Component& target, const PointOrRect& coordInParent)
|
||||
static PointOrRect convertFromDistantParentSpace (const Component* parent, const Component& target, PointOrRect coordInParent)
|
||||
{
|
||||
auto* directParent = target.getParentComponent();
|
||||
jassert (directParent != nullptr);
|
||||
|
|
@ -2495,9 +2495,9 @@ void Component::internalMagnifyGesture (MouseInputSource source, Point<float> re
|
|||
BailOutChecker checker (this);
|
||||
|
||||
const MouseEvent me (source, relativePos, source.getCurrentModifiers(), MouseInputSource::invalidPressure,
|
||||
MouseInputSource::invalidOrientation, MouseInputSource::invalidRotation,
|
||||
MouseInputSource::invalidTiltX, MouseInputSource::invalidTiltY,
|
||||
this, this, time, relativePos, time, 0, false);
|
||||
MouseInputSource::invalidOrientation, MouseInputSource::invalidRotation,
|
||||
MouseInputSource::invalidTiltX, MouseInputSource::invalidTiltY,
|
||||
this, this, time, relativePos, time, 0, false);
|
||||
|
||||
if (isCurrentlyBlockedByAnotherModalComponent())
|
||||
{
|
||||
|
|
@ -2520,7 +2520,7 @@ void Component::internalMagnifyGesture (MouseInputSource source, Point<float> re
|
|||
|
||||
void Component::sendFakeMouseMove() const
|
||||
{
|
||||
MouseInputSource mainMouse = Desktop::getInstance().getMainMouseSource();
|
||||
auto mainMouse = Desktop::getInstance().getMainMouseSource();
|
||||
|
||||
if (! mainMouse.isDragging())
|
||||
mainMouse.triggerFakeMove();
|
||||
|
|
@ -2862,20 +2862,25 @@ bool Component::isMouseOver (bool includeChildren) const
|
|||
{
|
||||
auto* c = ms.getComponentUnderMouse();
|
||||
|
||||
if ((c == this || (includeChildren && isParentOf (c)))
|
||||
&& c->reallyContains (c->getLocalPoint (nullptr, ms.getScreenPosition().roundToInt()), false)
|
||||
&& ((! ms.isTouch()) || ms.isDragging()))
|
||||
return true;
|
||||
if (c == this || (includeChildren && isParentOf (c)))
|
||||
if (ms.isDragging() || ! ms.isTouch())
|
||||
if (c->reallyContains (c->getLocalPoint (nullptr, ms.getScreenPosition()).roundToInt(), false))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Component::isMouseButtonDown() const
|
||||
bool Component::isMouseButtonDown (bool includeChildren) const
|
||||
{
|
||||
for (auto& ms : Desktop::getInstance().getMouseSources())
|
||||
if (ms.isDragging() && ms.getComponentUnderMouse() == this)
|
||||
return true;
|
||||
{
|
||||
auto* c = ms.getComponentUnderMouse();
|
||||
|
||||
if (c == this || (includeChildren && isParentOf (c)))
|
||||
if (ms.isDragging())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2886,9 +2891,9 @@ bool Component::isMouseOverOrDragging (bool includeChildren) const
|
|||
{
|
||||
auto* c = ms.getComponentUnderMouse();
|
||||
|
||||
if ((c == this || (includeChildren && isParentOf (c)))
|
||||
&& ((! ms.isTouch()) || ms.isDragging()))
|
||||
return true;
|
||||
if (c == this || (includeChildren && isParentOf (c)))
|
||||
if (ms.isDragging() || ! ms.isTouch())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -2919,8 +2924,8 @@ void Component::removeKeyListener (KeyListener* listenerToRemove)
|
|||
keyListeners->removeFirstMatchingValue (listenerToRemove);
|
||||
}
|
||||
|
||||
bool Component::keyPressed (const KeyPress&) { return false; }
|
||||
bool Component::keyStateChanged (const bool /*isKeyDown*/) { return false; }
|
||||
bool Component::keyPressed (const KeyPress&) { return false; }
|
||||
bool Component::keyStateChanged (bool /*isKeyDown*/) { return false; }
|
||||
|
||||
void Component::modifierKeysChanged (const ModifierKeys& modifiers)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1791,7 +1791,7 @@ public:
|
|||
|
||||
@see isMouseButtonDownAnywhere, isMouseOver, isMouseOverOrDragging
|
||||
*/
|
||||
bool isMouseButtonDown() const;
|
||||
bool isMouseButtonDown (bool includeChildren = false) const;
|
||||
|
||||
/** True if the mouse is over this component, or if it's being dragged in this component.
|
||||
This is a handy equivalent to (isMouseOver() || isMouseButtonDown()).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue