From e2e4428f0ffa79a032f56812dd89f0b8b8af63f9 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 5 Aug 2022 13:49:09 +0200 Subject: iOS: ensure we close inputpanel after clearing focusobject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change 7f72622c0f caused a regression where the input panel would not close automatically when the focus object was cleared. The reason is that it's apparently not enough to just release the first responder, we also need to explicitly tell it to release it's first responder status. Before the failing patch, we did this from within update(). This patch will instead/in addition do an extra check from inside reset(). Fixes: QTBUG-105323 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: I00bdd44fe54db69f44232226291e3c5715935749 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.mm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index e30ccc2c84..4c4b213ba2 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -712,11 +712,20 @@ void QIOSInputContext::reset() // Instead, we choose to recreate the text responder as a brute-force solution // until we have better knowledge of what is going on (or implement the new // UITextInteraction protocol). + const auto oldResponder = m_textResponder; [m_textResponder reset]; [m_textResponder autorelease]; m_textResponder = nullptr; update(Qt::ImQueryAll); + + // If update() didn't end up creating a new text responder, oldResponder will still be + // the first responder. In that case we need to resign it, so that the input panel hides. + // (the input panel will apparently not hide if the first responder is only released). + if ([oldResponder isFirstResponder]) { + qImDebug("IM not enabled, resigning autoreleased text responder as first responder"); + [oldResponder resignFirstResponder]; + } } /*! -- cgit v1.2.3