diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 4f7c30c907..e02efdb01f 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -997,7 +997,7 @@ public: } //============================================================================== - bool sendModalInputAttemptIfBlocked() + bool isBlockedByModalComponent() { if (auto* modal = Component::getCurrentlyModalComponent()) { @@ -1005,7 +1005,6 @@ public: && (! getComponent().isParentOf (modal)) && getComponent().isCurrentlyBlockedByAnotherModalComponent()) { - modal->inputAttemptWhenModal(); return true; } } @@ -1013,6 +1012,13 @@ public: return false; } + void sendModalInputAttemptIfBlocked() + { + if (isBlockedByModalComponent()) + if (auto* modal = Component::getCurrentlyModalComponent()) + modal->inputAttemptWhenModal(); + } + bool canBecomeKeyWindow() { return component.isVisible() && (getStyleFlags() & juce::ComponentPeer::windowIgnoresKeyPresses) == 0; @@ -1988,7 +1994,7 @@ private: return owner != nullptr && owner->canBecomeKeyWindow() - && ! owner->sendModalInputAttemptIfBlocked(); + && ! owner->isBlockedByModalComponent(); } static BOOL canBecomeMainWindow (id self, SEL) @@ -1997,7 +2003,7 @@ private: return owner != nullptr && owner->canBecomeMainWindow() - && ! owner->sendModalInputAttemptIfBlocked(); + && ! owner->isBlockedByModalComponent(); } static void becomeKeyWindow (id self, SEL)