From 73654ee53516aac58a363695debc9fd5520e4fe8 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 5 Jun 2017 10:15:45 +0100 Subject: [PATCH] Added a method to TextPropertyComponent to set whether it should respond to file drag and drop --- .../properties/juce_TextPropertyComponent.cpp | 14 +++++++++++++- .../properties/juce_TextPropertyComponent.h | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp index d09ed7f56d..3193f110bf 100644 --- a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp @@ -41,7 +41,7 @@ public: bool isInterestedInFileDrag (const StringArray&) override { - return true; + return interestedInFileDrag; } void filesDropped (const StringArray& files, int, int) override @@ -77,10 +77,16 @@ public: repaint(); } + void setInterestedInFileDrag (bool isInterested) + { + interestedInFileDrag = isInterested; + } + private: TextPropertyComponent& owner; int maxChars; bool isMultiline; + bool interestedInFileDrag = true; }; //============================================================================== @@ -169,3 +175,9 @@ void TextPropertyComponent::colourChanged() PropertyComponent::colourChanged(); textEditor->updateColours(); } + +void TextPropertyComponent::setInterestedInFileDrag (bool isInterested) +{ + if (textEditor != nullptr) + textEditor->setInterestedInFileDrag (isInterested); +} diff --git a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h index e0b4c84e80..5a10ca6f5e 100644 --- a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h @@ -122,6 +122,14 @@ public: */ void removeListener (Listener* listener); + //============================================================================== + /** Sets whether the text property component can have files dropped onto it by an external application. + + The default setting for this is true but you may want to disable this behaviour if you derive + from this class and want your subclass to respond to the file drag. + */ + void setInterestedInFileDrag (bool isInterested); + //============================================================================== /** @internal */ void refresh() override;