1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

NSViewComponentPeer: Ensure inner views that receive key equivalents reset keyDown state correctly

This commit is contained in:
reuk 2023-05-12 18:48:29 +01:00
parent 3d172f9c0d
commit cf7c865432
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -2235,8 +2235,33 @@ struct JuceNSViewClass : public NSViewComponentPeerWrapper<ObjCClass<NSView>>
addMethod (@selector (performKeyEquivalent:), [] (id self, SEL s, NSEvent* ev) -> BOOL
{
if (auto* owner = getOwner (self))
{
const auto ref = owner->safeComponent;
if (owner->sendEventToInputContextOrComponent (ev))
{
if (ref == nullptr)
return YES;
const auto isFirstResponder = [&]
{
if (auto* v = owner->view)
if (auto* w = v.window)
return w.firstResponder == self;
return false;
}();
// If the view isn't the first responder, but the view has successfully
// performed the key equivalent, then the key event must have been passed down
// the view hierarchy to this point. In that case, the view won't be sent a
// matching keyUp event, so we simulate it here.
if (! isFirstResponder)
owner->redirectKeyUp (ev);
return YES;
}
}
return sendSuperclassMessage<BOOL> (self, s, ev);
});