From a9283f48fa1f2a51c9a57e5635a6a61dfabc54d2 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 23 Mar 2018 16:19:16 +0000 Subject: [PATCH] Added a lambda callback to ValueWithDefault that will be called when the default value is changed --- .../juce_data_structures/values/juce_ValueWithDefault.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/juce_data_structures/values/juce_ValueWithDefault.h b/modules/juce_data_structures/values/juce_ValueWithDefault.h index 002f9a1d4b..518bbd6b12 100644 --- a/modules/juce_data_structures/values/juce_ValueWithDefault.h +++ b/modules/juce_data_structures/values/juce_ValueWithDefault.h @@ -94,7 +94,12 @@ public: void setDefault (const var& newDefault) { if (defaultValue != newDefault) + { defaultValue = newDefault; + + if (onDefaultChange != nullptr) + onDefaultChange(); + } } /** Returns true if the property does not exist or is empty. */ @@ -109,6 +114,9 @@ public: targetTree.removeProperty (targetProperty, nullptr); } + /** You can assign a lambda to this callback object to have it called when the default value is changed. */ + std::function onDefaultChange; + //============================================================================== /** Sets the property and returns the new ValueWithDefault. This will modify the property in the referenced ValueTree. */ ValueWithDefault& operator= (const var& newValue)