From 530dca28a58e6f130a33cd2dbfcdc7dc14844130 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 29 Oct 2013 13:21:02 +0000 Subject: [PATCH] Made sure that CalloutBoxes disappear when clicking on another app. --- .../juce_gui_basics/windows/juce_CallOutBox.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp index 63d7459d7b..f2fa91ba1f 100644 --- a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp +++ b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp @@ -48,8 +48,11 @@ CallOutBox::~CallOutBox() { } +enum { callOutBoxDismissCommandId = 0x4f83a04b }; + //============================================================================== -class CallOutBoxCallback : public ModalComponentManager::Callback +class CallOutBoxCallback : public ModalComponentManager::Callback, + private Timer { public: CallOutBoxCallback (Component* c, const Rectangle& area, Component* parent) @@ -57,9 +60,16 @@ public: { callout.setVisible (true); callout.enterModalState (true, this); + startTimer (200); } - void modalStateFinished (int) {} + void modalStateFinished (int) override {} + + void timerCallback() override + { + if (! Process::isForegroundProcess()) + callout.postCommandMessage (callOutBoxDismissCommandId); + } ScopedPointer content; CallOutBox callout; @@ -110,8 +120,6 @@ bool CallOutBox::hitTest (int x, int y) return outline.contains ((float) x, (float) y); } -enum { callOutBoxDismissCommandId = 0x4f83a04b }; - void CallOutBox::inputAttemptWhenModal() { const Point mousePos (getMouseXYRelative() + getBounds().getPosition());