diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 2a4c4e5c6a..0d4f0da5b2 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -521,9 +521,7 @@ public: void setTextBoxIsEditable (const bool shouldBeEditable) { editableText = shouldBeEditable; - - if (valueBox != nullptr) - valueBox->setEditable (shouldBeEditable && owner.isEnabled()); + updateTextBoxEnablement(); } void showTextBox() @@ -554,6 +552,17 @@ public: } } + void updateTextBoxEnablement() + { + if (valueBox != nullptr) + { + const bool shouldBeEditable = editableText && owner.isEnabled(); + + if (valueBox->isEditable() != shouldBeEditable) // (to avoid changing the single/double click flags unless we need to) + valueBox->setEditable (shouldBeEditable); + } + } + void lookAndFeelChanged (LookAndFeel& lf) { if (textBoxPos != NoTextBox) @@ -567,10 +576,7 @@ public: valueBox->setWantsKeyboardFocus (false); valueBox->setText (previousTextBoxContent, dontSendNotification); valueBox->setTooltip (owner.getTooltip()); - - if (valueBox->isEditable() != editableText) // (avoid overriding the single/double click flags unless we have to) - valueBox->setEditable (editableText && owner.isEnabled()); - + updateTextBoxEnablement(); valueBox->addListener (this); if (style == LinearBar || style == LinearBarVertical) @@ -1450,7 +1456,7 @@ Component* Slider::getCurrentPopupDisplay() const noexcept { return pimpl-> //============================================================================== void Slider::colourChanged() { lookAndFeelChanged(); } void Slider::lookAndFeelChanged() { pimpl->lookAndFeelChanged (getLookAndFeel()); } -void Slider::enablementChanged() { repaint(); } +void Slider::enablementChanged() { repaint(); pimpl->updateTextBoxEnablement(); } //============================================================================== double Slider::getMaximum() const noexcept { return pimpl->maximum; }