iOS: ensure we close inputpanel after clearing focusobject

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
Change-Id: I00bdd44fe54db69f44232226291e3c5715935749
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit e2e4428f0ffa79a032f56812dd89f0b8b8af63f9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Richard Moe Gustavsen 2022-08-05 13:49:09 +02:00 committed by Qt Cherry-pick Bot
parent 5358cdd0bc
commit 5f953d02d4

View File

@ -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];
}
}
/*!