aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktextinput
diff options
context:
space:
mode:
authorBartlomiej Moskal <bartlomiej.moskal@qt.io>2022-10-04 13:57:31 +0200
committerBartlomiej Moskal <bartlomiej.moskal@qt.io>2022-11-16 09:10:34 +0200
commit9dc305379baf64828bb6df5bd3a5f6d2bbcb90ba (patch)
treec353304d7a3b71bb1a6d855a32536077dab067d0 /tests/auto/quick/qquicktextinput
parent6b03bc92739d7ae5f38093162ec9d2ca25ff8906 (diff)
Android: Set EnterKeyNext as default type for TextInput
Behavior of EnterKey for virtual keyboard need to be changed for TextInput. Before this commit, ImeOption was set to IME_ACTION_DONE. Beacuse of that, setting any text in TextInput automatically accept QDialogs. That was annoying, when more than one QLineEdit need to be set. [ChangeLog][Quick][Android] EnterKey type is now changed from EnterKeyDefault to EnterKeyNext for virtual keyboard in TextInput. It is done only if the focus can be moved to QQuickItem below, so the activeFocusOnTab need to be set. Fixes: QTBUG-61652 Change-Id: Ib2faf78f4c85788498476c1e67e67d29d508cfea Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktextinput')
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 9475d63930..267b9c10a0 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -94,6 +94,8 @@ private slots:
void validators();
void inputMethods();
+ void inputMethodQueryEnterKeyType();
+
void signal_accepted();
void signal_editingfinished();
void signal_textEdited();
@@ -2302,6 +2304,36 @@ void tst_qquicktextinput::inputMethods()
QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), false);
}
+void tst_qquicktextinput::inputMethodQueryEnterKeyType()
+{
+ QQuickView view(testFileUrl("focusReason.qml"));
+
+ QQuickTextInput *first = view.rootObject()->findChild<QQuickTextInput *>("first");
+ QQuickTextInput *second = view.rootObject()->findChild<QQuickTextInput *>("second");
+ QQuickTextInput *third = view.rootObject()->findChild<QQuickTextInput *>("third");
+ QVERIFY(first && second && third);
+
+ first->setActiveFocusOnTab(true);
+ second->setActiveFocusOnTab(true);
+ third->setActiveFocusOnTab(true);
+
+ view.show();
+
+ QVariant enterTypeFirst = first->inputMethodQuery(Qt::ImEnterKeyType);
+ QVariant enterTypeSecond = second->inputMethodQuery(Qt::ImEnterKeyType);
+ QVariant enterTypeThird = third->inputMethodQuery(Qt::ImEnterKeyType);
+#ifdef Q_OS_ANDROID
+ // QTBUG-61652
+ // EnterKey is changed to EnterKeyNext if the focus can be moved to item below
+ QCOMPARE(enterTypeFirst.value<Qt::EnterKeyType>(), Qt::EnterKeyNext);
+ QCOMPARE(enterTypeSecond.value<Qt::EnterKeyType>(), Qt::EnterKeyNext);
+#else
+ QCOMPARE(enterTypeFirst.value<Qt::EnterKeyType>(), Qt::EnterKeyDefault);
+ QCOMPARE(enterTypeSecond.value<Qt::EnterKeyType>(), Qt::EnterKeyDefault);
+#endif
+ QCOMPARE(enterTypeThird.value<Qt::EnterKeyType>(), Qt::EnterKeyDefault);
+}
+
void tst_qquicktextinput::signal_accepted()
{
QQuickView window(testFileUrl("signal_accepted.qml"));