diff --git a/modules/juce_gui_basics/widgets/juce_Label.cpp b/modules/juce_gui_basics/widgets/juce_Label.cpp index 1d1f66a70e..bafa26144e 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -191,6 +191,12 @@ void Label::editorShown (TextEditor* textEditor) { Component::BailOutChecker checker (this); listeners.callChecked (checker, [this, textEditor] (Label::Listener& l) { l.editorShown (this, *textEditor); }); + + if (checker.shouldBailOut()) + return; + + if (onEditorShow != nullptr) + onEditorShow(); } void Label::editorAboutToBeHidden (TextEditor* textEditor) @@ -200,6 +206,12 @@ void Label::editorAboutToBeHidden (TextEditor* textEditor) Component::BailOutChecker checker (this); listeners.callChecked (checker, [this, textEditor] (Label::Listener& l) { l.editorHidden (this, *textEditor); }); + + if (checker.shouldBailOut()) + return; + + if (onEditorHide != nullptr) + onEditorHide(); } void Label::showEditor() @@ -404,6 +416,12 @@ void Label::callChangeListeners() { Component::BailOutChecker checker (this); listeners.callChecked (checker, [this] (Listener& l) { l.labelTextChanged (this); }); + + if (checker.shouldBailOut()) + return; + + if (onTextChange != nullptr) + onTextChange(); } //============================================================================== diff --git a/modules/juce_gui_basics/widgets/juce_Label.h b/modules/juce_gui_basics/widgets/juce_Label.h index 0aee949994..ac86644fc9 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.h +++ b/modules/juce_gui_basics/widgets/juce_Label.h @@ -200,6 +200,16 @@ public: /** Deregisters a previously-registered listener. */ void removeListener (Listener* listener); + //============================================================================== + /** You can assign a lambda to this callback object to have it called when the label text is changed. */ + std::function onTextChange; + + /** You can assign a lambda to this callback object to have it called when the label's editor is shown. */ + std::function onEditorShow; + + /** You can assign a lambda to this callback object to have it called when the label's editor is hidden. */ + std::function onEditorHide; + //============================================================================== /** Makes the label turn into a TextEditor when clicked. diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 9ccfeeab70..ca3884a50d 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -320,6 +320,12 @@ public: Component::BailOutChecker checker (&owner); listeners.callChecked (checker, [&] (Slider::Listener& l) { l.sliderValueChanged (&owner); }); + + if (checker.shouldBailOut()) + return; + + if (owner.onValueChange != nullptr) + owner.onValueChange(); } void sendDragStart() @@ -328,6 +334,12 @@ public: Component::BailOutChecker checker (&owner); listeners.callChecked (checker, [&] (Slider::Listener& l) { l.sliderDragStarted (&owner); }); + + if (checker.shouldBailOut()) + return; + + if (owner.onDragStart != nullptr) + owner.onDragStart(); } void sendDragEnd() @@ -337,6 +349,12 @@ public: Component::BailOutChecker checker (&owner); listeners.callChecked (checker, [&] (Slider::Listener& l) { l.sliderDragEnded (&owner); }); + + if (checker.shouldBailOut()) + return; + + if (owner.onDragEnd != nullptr) + owner.onDragEnd(); } struct DragInProgress diff --git a/modules/juce_gui_basics/widgets/juce_Slider.h b/modules/juce_gui_basics/widgets/juce_Slider.h index 791c7951c0..f21f9d9241 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.h +++ b/modules/juce_gui_basics/widgets/juce_Slider.h @@ -586,6 +586,16 @@ public: /** Removes a previously-registered listener. */ void removeListener (Listener* listener); + //============================================================================== + /** You can assign a lambda to this callback object to have it called when the slider value is changed. */ + std::function onValueChange; + + /** You can assign a lambda to this callback object to have it called when the slider's drag begins. */ + std::function onDragStart; + + /** You can assign a lambda to this callback object to have it called when the slider's drag ends. */ + std::function onDragEnd; + //============================================================================== /** This lets you choose whether double-clicking moves the slider to a given position.