aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2023-04-12 13:41:57 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-18 08:10:05 +0000
commitd0c73a757048cfffd7ab824d0ff8685295197af7 (patch)
treec9510f284b6b9ea7e91ee24adef8f9c7a61940b6
parent5b7e125ddfb22451602298f54831ed57446e9b7d (diff)
Fix word selection on touch
The cursor position update on mouseReleaseEvent broke touch-and-hold word selection on touch devices. Now only do it if we don't have an active selection. Fixes: QTBUG-111504 Fixes: QTBUG-110850 Change-Id: I5c63d8516d1eef3de10289c6d5c5b3d1d3e8623f Reviewed-by: Sami Varanka <sami.varanka@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit d6ddfa3d4ca3fbbaddc2acd7ebe3f8296fc68b68) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quick/items/qquicktextinput.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 61844ca0e1..660496734b 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -1648,9 +1648,11 @@ void QQuickTextInput::mouseReleaseEvent(QMouseEvent *event)
}
}
#endif
+
// On a touchscreen or with a stylus, set cursor position and focus on release, not on press;
// if Flickable steals the grab in the meantime, the cursor won't move.
- if (!isMouse)
+ // Check d->hasSelectedText() to keep touch-and-hold word selection working.
+ if (!isMouse && !d->hasSelectedText())
d->moveCursor(d->positionAt(event->position()), false);
if (d->focusOnPress && qGuiApp->styleHints()->setFocusOnTouchRelease())