Android: Clear QtEditText focus after keyboard is hidden

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 <assam.boudjelthia@qt.io>
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
(cherry picked from commit dc71864d4a358149a2531d324645934e47879dba)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Petri Virkkunen 2024-08-14 14:15:59 +03:00 committed by Qt Cherry-pick Bot
parent f35cc3a115
commit b48b0dba63
2 changed files with 5 additions and 2 deletions

View File

@ -286,9 +286,11 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener, Qt
m_keyboardIsVisible = visibility; m_keyboardIsVisible = visibility;
keyboardVisibilityUpdated(m_keyboardIsVisible); 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_keyboardVisibilityListener.onKeyboardVisibilityChange();
m_currentEditText.clearFocus();
}
} }
void setFocusedView(QtEditText currentEditText) void setFocusedView(QtEditText currentEditText)

View File

@ -32,6 +32,7 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
m_inputConnectionListener = listener; m_inputConnectionListener = listener;
setParent(parentWindow); setParent(parentWindow);
setFocusableInTouchMode(true); setFocusableInTouchMode(true);
setDefaultFocusHighlightEnabled(false);
// Views are by default visible, but QWindows are not. // Views are by default visible, but QWindows are not.
// We should ideally pick up the actual QWindow state here, // We should ideally pick up the actual QWindow state here,