Android: Fix Android keyboard hiding focused QtEditText

Update QtEditText Layout parameters to match the item sending
the focus event while showing Android keyboard.

Task-number: QTBUG-125323
Change-Id: Ie7f32d66807e4c1d308d49483d1e72dc25eaa76a
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
(cherry picked from commit 28df9a49776a88cb1a8e69348ae19a59b16a5b7e)
This commit is contained in:
Konsta Alajärvi 2024-09-18 10:17:44 +03:00
parent 83d933ef07
commit a3af3505ef
3 changed files with 6 additions and 7 deletions

View File

@ -267,11 +267,7 @@ class QtEditText extends View
break;
case CursorHandleShowNormal:
if (m_cursorHandle == null) {
// We pass this to the CursorHandle to use the QtEditText to calculate its
// position. This is OK as the QtEditText size matches the QtWindow size.
// If the size of the QtEditText is changed to not reflect the window's anymore,
// this should be changed to use getParent() instead of this.
m_cursorHandle = new CursorHandle((Activity) getContext(), this,
m_cursorHandle = new CursorHandle((Activity) getContext(), (View) getParent(),
CursorHandle.IdCursorHandle,
android.R.attr.textSelectHandle, false);
}

View File

@ -104,6 +104,9 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener, Qt
return;
m_currentEditText.setEditTextOptions(enterKeyType, inputHints);
m_currentEditText.setLayoutParams(new QtLayout.LayoutParams(width, height, x, y));
m_currentEditText.requestFocus();
m_currentEditText.postDelayed(() -> {

View File

@ -44,8 +44,8 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
if (!isForeignWindow) {
m_editText = new QtEditText(context, listener);
addView(m_editText, new QtLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
addView(m_editText, new QtLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
m_editText.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
} else {
m_editText = null;