From 8d6169fbf5779e12e1a063eee3e9962c4f769aa7 Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 19 Oct 2022 19:52:26 +0100 Subject: [PATCH] NSViewComponentPeer: Avoid processing key events directly during IME composition This fixes an issue where e.g. pressing 'return' to select an item from an IME list would directly insert a newline character, rather than selecting the entry. --- .../native/juce_mac_NSViewComponentPeer.mm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 8987a60f14..65b588f92b 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -1590,7 +1590,7 @@ public: #else bool usingCoreGraphics = false; #endif - bool isZooming = false, isFirstLiveResize = false, textWasInserted = false; + bool textWasInserted = false, isFirstLiveResize = false; bool isStretchingTop = false, isStretchingLeft = false, isStretchingBottom = false, isStretchingRight = false; bool windowRepresentsFile = false; bool isAlwaysOnTop = false, wasAlwaysOnTop = false; @@ -2007,15 +2007,14 @@ struct JuceNSViewClass : public NSViewComponentPeerWrapper> { if (auto* owner = getOwner (self)) { - auto* target = owner->findCurrentTextInputTarget(); owner->textWasInserted = false; - if (target != nullptr) + if (auto* target = owner->findCurrentTextInputTarget()) [(NSView*) self interpretKeyEvents: [NSArray arrayWithObject: ev]]; else owner->stringBeingComposed.clear(); - if (! (owner->textWasInserted || owner->redirectKeyDown (ev))) + if (! (owner->textWasInserted || owner->stringBeingComposed.isNotEmpty() || owner->redirectKeyDown (ev))) sendSuperclassMessage (self, @selector (keyDown:), ev); } }); @@ -2367,7 +2366,7 @@ struct JuceNSWindowClass : public NSViewComponentPeerWrapperisZooming) + if (owner == nullptr) return proposedFrameSize; NSRect frameRect = flippedScreenRect ([(NSWindow*) self frame]);