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

FileChooser: Find an appropriate peer to focus when the FileChooser is destroyed

This works around a rare issue in the DialogsDemo where the AlertWindow
would fail to display because no peer had focus.
This commit is contained in:
reuk 2021-12-15 17:02:48 +00:00
parent 038d6dff32
commit 0cec50618d
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -131,6 +131,16 @@ public:
~Native() override
{
exitModalState (0);
// Our old peer may not have received a becomeFirstResponder call at this point,
// so the static currentlyFocusedPeer may be null.
// We'll try to find an appropriate peer to focus.
for (auto i = 0; i < ComponentPeer::getNumPeers(); ++i)
if (auto* p = ComponentPeer::getPeer (i))
if (p != getPeer())
if (auto* view = (UIView*) p->getNativeHandle())
[view becomeFirstResponder];
}
void launch() override