Android: Allow to open Keyboard without touch

After changes in f4050cc5ea7490ba3b8b2bb0a174559d7e72a27e commit, the
keyboard can be opened only when internal m_currentEditText is set (what
is happening only on touch). Because of that, the keyboard cannot be
opened just by setting focus on an item like it was before.

To allow open the keyboard not only after touch, QtWindow needs to be
informed about each focus change.

Fixes: QTBUG-124360
Change-Id: Ic3ca4451f53df55bfb1f3e300078fd1916e77155
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 2971dbfe062de6b0be3ed9f251f9506bd45d5854)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Bartlomiej Moskal 2024-09-17 09:20:08 +02:00 committed by Qt Cherry-pick Bot
parent 4cbef8822a
commit b60db83faa
4 changed files with 16 additions and 1 deletions

View File

@ -236,4 +236,11 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
if (m_parentWindow != null) if (m_parentWindow != null)
m_parentWindow.addChildWindow(this); m_parentWindow.addChildWindow(this);
} }
@UsedFromNativeCode
void updateFocusedEditText()
{
if (m_editText != null && m_inputConnectionListener != null)
m_inputConnectionListener.onEditTextChanged(m_editText);
}
} }

View File

@ -299,8 +299,10 @@ void QAndroidPlatformScreen::topVisibleWindowChanged()
QtAndroidMenu::setActiveTopLevelWindow(w); QtAndroidMenu::setActiveTopLevelWindow(w);
if (w && w->handle()) { if (w && w->handle()) {
QAndroidPlatformWindow *platformWindow = static_cast<QAndroidPlatformWindow *>(w->handle()); QAndroidPlatformWindow *platformWindow = static_cast<QAndroidPlatformWindow *>(w->handle());
if (platformWindow) if (platformWindow) {
platformWindow->updateSystemUiVisibility(); platformWindow->updateSystemUiVisibility();
platformWindow->updateFocusedEditText();
}
} }
} }

View File

@ -266,6 +266,11 @@ void QAndroidPlatformWindow::updateSystemUiVisibility()
} }
} }
void QAndroidPlatformWindow::updateFocusedEditText()
{
m_nativeQtWindow.callMethod<void>("updateFocusedEditText");
}
bool QAndroidPlatformWindow::isExposed() const bool QAndroidPlatformWindow::isExposed() const
{ {
return qApp->applicationState() > Qt::ApplicationHidden return qApp->applicationState() > Qt::ApplicationHidden

View File

@ -57,6 +57,7 @@ public:
void propagateSizeHints() override; void propagateSizeHints() override;
void requestActivateWindow() override; void requestActivateWindow() override;
void updateSystemUiVisibility(); void updateSystemUiVisibility();
void updateFocusedEditText();
inline bool isRaster() const { return m_isRaster; } inline bool isRaster() const { return m_isRaster; }
bool isExposed() const override; bool isExposed() const override;
QtJniTypes::QtWindow nativeWindow() const { return m_nativeQtWindow; } QtJniTypes::QtWindow nativeWindow() const { return m_nativeQtWindow; }