diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 13e90c6742..47eaa9af5b 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -325,7 +325,7 @@ struct Component::ComponentHelpers } template - 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 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 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) { diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 404af095c9..5265b94a78 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -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()).