diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index f1ca46ccef..654d4f6b18 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -1120,12 +1120,15 @@ public: name: NSWindowWillMiniaturizeNotification object: currentWindow]; - #if JUCE_COREGRAPHICS_DRAW_ASYNC [notificationCenter addObserver: view selector: becomeKeySelector name: NSWindowDidBecomeKeyNotification object: currentWindow]; - #endif + + [notificationCenter addObserver: view + selector: resignKeySelector + name: NSWindowDidResignKeyNotification + object: currentWindow]; } } @@ -1140,6 +1143,12 @@ public: component.repaint(); } + void resignKey() + { + viewFocusLoss(); + sendModalInputAttemptIfBlocked(); + } + void liveResizingStart() { if (constrainer == nullptr) @@ -1516,6 +1525,7 @@ public: static const SEL asyncMouseDownSelector; static const SEL asyncMouseUpSelector; static const SEL becomeKeySelector; + static const SEL resignKeySelector; private: static NSView* createViewInstance(); @@ -1691,6 +1701,7 @@ const SEL NSViewComponentPeer::frameChangedSelector = @selector (frameChanged: const SEL NSViewComponentPeer::asyncMouseDownSelector = @selector (asyncMouseDown:); const SEL NSViewComponentPeer::asyncMouseUpSelector = @selector (asyncMouseUp:); const SEL NSViewComponentPeer::becomeKeySelector = @selector (becomeKey:); +const SEL NSViewComponentPeer::resignKeySelector = @selector (resignKey:); JUCE_END_IGNORE_WARNINGS_GCC_LIKE //============================================================================== @@ -1796,6 +1807,7 @@ struct JuceNSViewClass : public NSViewComponentPeerWrapper> addMethod (NSViewComponentPeer::asyncMouseUpSelector, asyncMouseUp, "v@:@"); addMethod (NSViewComponentPeer::frameChangedSelector, frameChanged, "v@:@"); addMethod (NSViewComponentPeer::becomeKeySelector, becomeKey, "v@:@"); + addMethod (NSViewComponentPeer::resignKeySelector, resignKey, "v@:@"); addMethod (@selector (performKeyEquivalent:), performKeyEquivalent, "c@:@"); @@ -1862,6 +1874,7 @@ private: static void viewDidMoveToWindow (id self, SEL) { if (auto* p = getOwner (self)) p->viewMovedToWindow(); } static void dismissModals (id self, SEL) { if (auto* p = getOwner (self)) p->dismissModals(); } static void becomeKey (id self, SEL) { if (auto* p = getOwner (self)) p->becomeKey(); } + static void resignKey (id self, SEL) { if (auto* p = getOwner (self)) p->resignKey(); } static BOOL isFlipped (id, SEL) { return true; }