Browse Source

Component: Give away keyboard focus when disabled

v6.1.6
ed 4 years ago
parent
commit
3fac215534
1 changed files with 9 additions and 0 deletions
  1. +9
    -0
      modules/juce_gui_basics/components/juce_Component.cpp

+ 9
- 0
modules/juce_gui_basics/components/juce_Component.cpp 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();
}
}
}


Loading…
Cancel
Save