From b48b0dba63428bc1a15f60cd4a741e3667b8f32f Mon Sep 17 00:00:00 2001 From: Petri Virkkunen Date: Wed, 14 Aug 2024 14:15:59 +0300 Subject: [PATCH] Android: Clear QtEditText focus after keyboard is hidden MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since QtEditText only needs focus for the virtual keyboard, focus should then be removed once we're done with the virtual keyboard. After this, focus will be received back by QtWindow, which will then handle key inputs properly. As a drive-by, remove the default focus highlight on QtWindow to stop the ugly flickering that happens when QtWindow receives focus back from QtEditText. Pick-to: 6.7 Task-number: QTBUG-126187 Change-Id: I911e3371d9c582b2805dc895ef49b0d4210714f3 Reviewed-by: Assam Boudjelthia Reviewed-by: Tinja Paavoseppä (cherry picked from commit dc71864d4a358149a2531d324645934e47879dba) Reviewed-by: Qt Cherry-pick Bot --- .../jar/src/org/qtproject/qt/android/QtInputDelegate.java | 6 ++++-- src/android/jar/src/org/qtproject/qt/android/QtWindow.java | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java index 6a18d4931bd..4178e1e35b5 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java @@ -286,9 +286,11 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener, Qt m_keyboardIsVisible = visibility; keyboardVisibilityUpdated(m_keyboardIsVisible); - // Hiding the keyboard clears the immersive mode, so we need to set it again. - if (!visibility) + if (!visibility) { + // Hiding the keyboard clears the immersive mode, so we need to set it again. m_keyboardVisibilityListener.onKeyboardVisibilityChange(); + m_currentEditText.clearFocus(); + } } void setFocusedView(QtEditText currentEditText) diff --git a/src/android/jar/src/org/qtproject/qt/android/QtWindow.java b/src/android/jar/src/org/qtproject/qt/android/QtWindow.java index 47b6371ffdb..bfe1009af45 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtWindow.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtWindow.java @@ -32,6 +32,7 @@ class QtWindow extends QtLayout implements QtSurfaceInterface { m_inputConnectionListener = listener; setParent(parentWindow); setFocusableInTouchMode(true); + setDefaultFocusHighlightEnabled(false); // Views are by default visible, but QWindows are not. // We should ideally pick up the actual QWindow state here,