1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-13 00:04:19 +00:00

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

This commit is contained in:
jules 2015-03-04 16:01:20 +00:00
parent cd48446e89
commit 3cee0e2c19

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