Browse Source

NSViewComponentPeer: Give up keyboard focus and dismiss temporary modals when window loses key status

v6.1.6
reuk 4 years ago
parent
commit
44ca96271d
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 15 additions and 2 deletions
  1. +15
    -2
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm

+ 15
- 2
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -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<ObjCClass<NSView>>
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; }


Loading…
Cancel
Save