From a4b83d313c9317326ca02f408341b2a3bc986eb3 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 11 Apr 2012 18:03:05 +0100 Subject: [PATCH] Prevented some mouse-events bypassing modal components. --- .../components/juce_Component.cpp | 80 ++++++++++--------- .../windows/juce_ComponentPeer.h | 2 +- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 53e64e1511..240d93c496 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -2384,61 +2384,67 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r void Component::internalMouseUp (MouseInputSource& source, const Point& relativePos, const Time& time, const ModifierKeys& oldModifiers) { - BailOutChecker checker (this); - - if (flags.repaintOnMouseActivityFlag) - repaint(); - - const MouseEvent me (source, relativePos, - oldModifiers, this, this, time, - getLocalPoint (nullptr, source.getLastMouseDownPosition()), - source.getLastMouseDownTime(), - source.getNumberOfMultipleClicks(), - source.hasMouseMovedSignificantlySincePressed()); - mouseUp (me); + if (! isCurrentlyBlockedByAnotherModalComponent()) + { + BailOutChecker checker (this); - if (checker.shouldBailOut()) - return; + if (flags.repaintOnMouseActivityFlag) + repaint(); - Desktop& desktop = Desktop::getInstance(); - desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseUp, me); + const MouseEvent me (source, relativePos, + oldModifiers, this, this, time, + getLocalPoint (nullptr, source.getLastMouseDownPosition()), + source.getLastMouseDownTime(), + source.getNumberOfMultipleClicks(), + source.hasMouseMovedSignificantlySincePressed()); + mouseUp (me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseUp, me); + if (checker.shouldBailOut()) + return; - if (checker.shouldBailOut()) - return; + Desktop& desktop = Desktop::getInstance(); + desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseUp, me); - // check for double-click - if (me.getNumberOfClicks() >= 2) - { - mouseDoubleClick (me); + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseUp, me); if (checker.shouldBailOut()) return; - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDoubleClick, me); + // check for double-click + if (me.getNumberOfClicks() >= 2) + { + mouseDoubleClick (me); + + if (checker.shouldBailOut()) + return; + + desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDoubleClick, me); + } } } void Component::internalMouseDrag (MouseInputSource& source, const Point& relativePos, const Time& time) { - BailOutChecker checker (this); + if (! isCurrentlyBlockedByAnotherModalComponent()) + { + BailOutChecker checker (this); - const MouseEvent me (source, relativePos, - source.getCurrentModifiers(), this, this, time, - getLocalPoint (nullptr, source.getLastMouseDownPosition()), - source.getLastMouseDownTime(), - source.getNumberOfMultipleClicks(), - source.hasMouseMovedSignificantlySincePressed()); - mouseDrag (me); + const MouseEvent me (source, relativePos, + source.getCurrentModifiers(), this, this, time, + getLocalPoint (nullptr, source.getLastMouseDownPosition()), + source.getLastMouseDownTime(), + source.getNumberOfMultipleClicks(), + source.hasMouseMovedSignificantlySincePressed()); + mouseDrag (me); - if (checker.shouldBailOut()) - return; + if (checker.shouldBailOut()) + return; - Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseDrag, me); + Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseDrag, me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDrag, me); + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDrag, me); + } } void Component::internalMouseMove (MouseInputSource& source, const Point& relativePos, const Time& time) diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.h b/modules/juce_gui_basics/windows/juce_ComponentPeer.h index ab3d15ae5a..8cc0461a3d 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.h +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.h @@ -59,7 +59,7 @@ public: windowIgnoresMouseClicks = (1 << 2), /**< Indicates that the window should let mouse clicks pass through it (may not be possible on some platforms). */ windowHasTitleBar = (1 << 3), /**< Indicates that the window should have a normal OS-specific - title bar and frame\. if not specified, the window will be + title bar and frame. if not specified, the window will be borderless. */ windowIsResizable = (1 << 4), /**< Indicates that the window should have a resizable border. */ windowHasMinimiseButton = (1 << 5), /**< Indicates that if the window has a title bar, it should have a