1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Component: Give away keyboard focus when disabled

This commit is contained in:
ed 2021-10-08 11:32:19 +01:00
parent a852f4f45f
commit 3fac215534

View file

@ -3007,6 +3007,15 @@ void Component::setEnabled (bool shouldBeEnabled)
BailOutChecker checker (this);
componentListeners.callChecked (checker, [this] (ComponentListener& l) { l.componentEnablementChanged (*this); });
if (! shouldBeEnabled && hasKeyboardFocus (true))
{
if (parentComponent != nullptr)
parentComponent->grabKeyboardFocus();
// ensure that keyboard focus is given away if it wasn't taken by parent
giveAwayKeyboardFocus();
}
}
}