From 5956d5bce0264ebd378612ceb2ee08a081d46410 Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 8 Mar 2014 14:18:51 +0000 Subject: [PATCH] Added a method CallOutBox::dismiss() --- modules/juce_gui_basics/windows/juce_CallOutBox.cpp | 13 +++++++++---- modules/juce_gui_basics/windows/juce_CallOutBox.h | 5 +++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp index 1276f43e2c..d9f4cf28da 100644 --- a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp +++ b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp @@ -48,8 +48,6 @@ CallOutBox::~CallOutBox() { } -enum { callOutBoxDismissCommandId = 0x4f83a04b }; - //============================================================================== class CallOutBoxCallback : public ModalComponentManager::Callback, private Timer @@ -68,7 +66,7 @@ public: void timerCallback() override { if (! Process::isForegroundProcess()) - callout.postCommandMessage (callOutBoxDismissCommandId); + callout.dismiss(); } ScopedPointer content; @@ -127,7 +125,7 @@ void CallOutBox::inputAttemptWhenModal() // if you click on the area that originally popped-up the callout, you expect it // to get rid of the box, but deleting the box here allows the click to pass through and // probably re-trigger it, so we need to dismiss the box asynchronously to consume the click.. - postCommandMessage (callOutBoxDismissCommandId); + dismiss(); } else { @@ -136,6 +134,8 @@ void CallOutBox::inputAttemptWhenModal() } } +enum { callOutBoxDismissCommandId = 0x4f83a04b }; + void CallOutBox::handleCommandMessage (int commandId) { Component::handleCommandMessage (commandId); @@ -147,6 +147,11 @@ void CallOutBox::handleCommandMessage (int commandId) } } +void CallOutBox::dismiss() +{ + postCommandMessage (callOutBoxDismissCommandId); +} + bool CallOutBox::keyPressed (const KeyPress& key) { if (key.isKeyCode (KeyPress::escapeKey)) diff --git a/modules/juce_gui_basics/windows/juce_CallOutBox.h b/modules/juce_gui_basics/windows/juce_CallOutBox.h index fab2e6b5fc..51be2f3e8b 100644 --- a/modules/juce_gui_basics/windows/juce_CallOutBox.h +++ b/modules/juce_gui_basics/windows/juce_CallOutBox.h @@ -118,6 +118,11 @@ public: const Rectangle& areaToPointTo, Component* parentComponent); + /** Posts a message which will dismiss the callout box asynchronously. + NB: it's safe to call this method from any thread. + */ + void dismiss(); + //============================================================================== /** This abstract base class is implemented by LookAndFeel classes. */ struct JUCE_API LookAndFeelMethods