From ba0cb5f2a92e7beb3df0746ea9b1cb2c637fb01b Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 18 Oct 2012 09:50:26 +0100 Subject: [PATCH] mouseUp behaviour fix when components are modal. --- .../juce_gui_basics/components/juce_Component.cpp | 12 +++++++----- modules/juce_gui_basics/components/juce_Component.h | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index c627bc7cae..ca06aa6f49 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -2286,11 +2286,11 @@ void Component::internalMouseExit (MouseInputSource& source, const Point& r void Component::internalMouseDown (MouseInputSource& source, const Point& relativePos, const Time& time) { Desktop& desktop = Desktop::getInstance(); - BailOutChecker checker (this); if (isCurrentlyBlockedByAnotherModalComponent()) { + flags.mouseDownWasBlocked = true; internalModalInputAttempt(); if (checker.shouldBailOut()) @@ -2310,6 +2310,8 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r } } + flags.mouseDownWasBlocked = false; + for (Component* c = this; c != nullptr; c = c->parentComponent) { if (c->isBroughtToFrontOnMouseClick()) @@ -2345,11 +2347,11 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDown, me); } -void Component::internalMouseUp (MouseInputSource& source, const Point& relativePos, const Time& time, const ModifierKeys& oldModifiers) +void Component::internalMouseUp (MouseInputSource& source, const Point& relativePos, + const Time& time, const ModifierKeys& oldModifiers) { - // NB: don't check whether there's a modal comp blocking this one, because if there is, it - // must have been created during a mouse-drag on this component, and if so, this comp will - // still want to get the corresponding mouse-up. + if (flags.mouseDownWasBlocked && isCurrentlyBlockedByAnotherModalComponent()) + return; BailOutChecker checker (this); diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 1797d757df..0a8cbb99c0 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -2255,6 +2255,7 @@ private: bool isDisabledFlag : 1; bool childCompFocusedFlag : 1; bool dontClipGraphicsFlag : 1; + bool mouseDownWasBlocked : 1; #if JUCE_DEBUG bool isInsidePaintCall : 1; #endif