mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
macOS: Propagate focus loss message when resigning key window status and only grab focus if window can become the key window
This commit is contained in:
parent
891d86fe6b
commit
f43784dc5b
1 changed files with 15 additions and 1 deletions
|
|
@ -1068,6 +1068,11 @@ public:
|
|||
grabFocus();
|
||||
}
|
||||
|
||||
void resignKeyWindow()
|
||||
{
|
||||
viewFocusLoss();
|
||||
}
|
||||
|
||||
bool windowShouldClose()
|
||||
{
|
||||
if (! isValidPeer (this))
|
||||
|
|
@ -1432,7 +1437,7 @@ public:
|
|||
|
||||
void grabFocus() override
|
||||
{
|
||||
if (window != nil)
|
||||
if (window != nil && [window canBecomeKeyWindow])
|
||||
{
|
||||
[window makeKeyWindow];
|
||||
[window makeFirstResponder: view];
|
||||
|
|
@ -2064,6 +2069,7 @@ struct JuceNSWindowClass : public ObjCClass<NSWindow>
|
|||
addMethod (@selector (canBecomeKeyWindow), canBecomeKeyWindow, "c@:");
|
||||
addMethod (@selector (canBecomeMainWindow), canBecomeMainWindow, "c@:");
|
||||
addMethod (@selector (becomeKeyWindow), becomeKeyWindow, "v@:");
|
||||
addMethod (@selector (resignKeyWindow), resignKeyWindow, "v@:");
|
||||
addMethod (@selector (windowShouldClose:), windowShouldClose, "c@:@");
|
||||
addMethod (@selector (constrainFrameRect:toScreen:), constrainFrameRect, @encode (NSRect), "@:", @encode (NSRect), "@");
|
||||
addMethod (@selector (windowWillResize:toSize:), windowWillResize, @encode (NSSize), "@:@", @encode (NSSize));
|
||||
|
|
@ -2125,6 +2131,14 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
static void resignKeyWindow (id self, SEL)
|
||||
{
|
||||
sendSuperclassMessage<void> (self, @selector (resignKeyWindow));
|
||||
|
||||
if (auto* owner = getOwner (self))
|
||||
owner->resignKeyWindow();
|
||||
}
|
||||
|
||||
static BOOL windowShouldClose (id self, SEL, id /*window*/)
|
||||
{
|
||||
auto* owner = getOwner (self);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue