mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
NSViewComponentPeer: Give up keyboard focus and dismiss temporary modals when window loses key status
This commit is contained in:
parent
c2f661171a
commit
44ca96271d
1 changed files with 15 additions and 2 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue