aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextinput.cpp
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 /src/quick/items/qquicktextinput.cpp
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 'src/quick/items/qquicktextinput.cpp')
-rw-r--r--src/quick/items/qquicktextinput.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index f944cfe7d7..f798fcd6a8 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -1972,6 +1972,29 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
#if QT_CONFIG(im)
QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property) const
{
+#ifdef Q_OS_ANDROID
+ // QTBUG-61652
+ if (property == Qt::ImEnterKeyType) {
+ Q_D(const QQuickItem);
+ // Do not change if type was set manually
+ if (!d->extra.isAllocated()
+ || d->extra->enterKeyAttached == nullptr
+ || d->extra->enterKeyAttached->type() == Qt::EnterKeyDefault) {
+
+ QQuickItem *next = const_cast<QQuickTextInput*>(this)->nextItemInFocusChain();
+ while (next && next != this && !next->activeFocusOnTab())
+ next = next->nextItemInFocusChain();
+ if (next) {
+ const auto nextYPos = next->mapToGlobal(QPoint(0, 0)).y();
+ const auto currentYPos = this->mapToGlobal(QPoint(0, 0)).y();
+ if (currentYPos < nextYPos)
+ // Set EnterKey to KeyNext type only if the next item
+ // in the focus chain is below current QQuickTextInput
+ return Qt::EnterKeyNext;
+ }
+ }
+ }
+#endif
return inputMethodQuery(property, QVariant());
}