From 3f9dbc0ec82e1c7c823707668fcd326d8a1dd82b Mon Sep 17 00:00:00 2001 From: Samuel Nevala Date: Wed, 22 Oct 2014 14:49:33 +0300 Subject: [PATCH] Android: Keyboard doesn't hide from done button QLineEdit commits and hides QInputMethod on enter key press. When Qt::ImhMultiLine input method hint is set, virtual keyboard is not hidden. Task-number: QTBUG-37850 Change-Id: I018351caa18bd2116665771e5f024a57182a01b9 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/widgets/widgets/qwidgetlinecontrol.cpp | 7 +++++++ tests/auto/shared/platforminputcontext.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 90fbfc1639..a82dd99591 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1607,6 +1607,13 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { if (hasAcceptableInput() || fixup()) { + + QInputMethod *inputMethod = QApplication::inputMethod(); + inputMethod->commit(); + QWidget *lineEdit = qobject_cast(parent()); + if (!(lineEdit && lineEdit->inputMethodHints() & Qt::ImhMultiLine)) + inputMethod->hide(); + emit accepted(); emit editingFinished(); } diff --git a/tests/auto/shared/platforminputcontext.h b/tests/auto/shared/platforminputcontext.h index fc415d833b..22b7ad6610 100644 --- a/tests/auto/shared/platforminputcontext.h +++ b/tests/auto/shared/platforminputcontext.h @@ -56,6 +56,8 @@ public: virtual void reset() { m_resetCallCount++; } virtual void commit() { m_commitCallCount++; + if (m_commitString.isEmpty()) + return; QInputMethodEvent commitEvent; commitEvent.setCommitString(m_commitString); if (qGuiApp->focusObject())