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

Ensure that keyboard focus is always given away when components are made invisible

This commit is contained in:
ed 2021-01-22 10:15:27 +00:00
parent f647c54b74
commit 33dd896ab2

View file

@ -489,7 +489,7 @@ Component::~Component()
if (parentComponent != nullptr)
parentComponent->removeChildComponent (parentComponent->childComponentList.indexOf (this), true, false);
else if (currentlyFocusedComponent == this || isParentOf (currentlyFocusedComponent))
else if (hasKeyboardFocus (true))
giveAwayFocus (currentlyFocusedComponent != this);
if (flags.hasHeavyweightPeerFlag)
@ -546,11 +546,12 @@ void Component::setVisible (bool shouldBeVisible)
{
ComponentHelpers::releaseAllCachedImageResources (*this);
if (currentlyFocusedComponent == this || isParentOf (currentlyFocusedComponent))
if (hasKeyboardFocus (true))
{
if (parentComponent != nullptr)
parentComponent->grabKeyboardFocus();
else
if (hasKeyboardFocus (true))
giveAwayFocus (true);
}
}