diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 245f0bb91d..2fc36410ec 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -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(); + } } }