Browse Source

Updates to Slider to keep the text box editability in sync when the parent is enabled.

tags/2021-05-28
jules 11 years ago
parent
commit
3cee0e2c19
1 changed files with 14 additions and 8 deletions
  1. +14
    -8
      modules/juce_gui_basics/widgets/juce_Slider.cpp

+ 14
- 8
modules/juce_gui_basics/widgets/juce_Slider.cpp View File

@@ -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; }


Loading…
Cancel
Save