diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-08-24 13:09:43 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-29 18:48:14 +0000 |
commit | dfd6170ebb9ce1b1106d8de953029a04279c616c (patch) | |
tree | 71b200861d918048228c543dce70cf1a7309062c /src | |
parent | cbef5bae849d1d8c079e0b5fdd3d63fff5616ab8 (diff) |
TextArea: selectByMouse default=true, but not on touchscreens
When you drag a finger across a TextArea, it should not select text.
- your finger probably covers several characters, so you can't see where
you're selecting until afterwards
- if the item is in a Flickable, flicking by touch should be prioritized
- if flicking happens, the text cursor should not move; but to avoid
losing too much functionality, we allow it to move on release, if
the TextArea gets the release (i.e. if it still has the exclusive
grab)
- TextArea's pressed, pressAndHold and released signals continue to
behave the same with touch as with mouse
As with the TextEdit change in 90d3fac73a10b9363fd34e6757cc730d7a0c086c,
we now distinguish mouse events that are synthesized from non-mouse
devices and avoid mouse-like behaviors as described above, but there is
no behavior change if the event comes from an actual mouse or touchpad.
In QQuickPressHandler::mousePressEvent() we give the original event's
device to the delayed press event, now that we check the device to
distinguish "real" mouse events from those that are synthesized from
touch.
[ChangeLog][Controls][TextArea] The selectByMouse property is now
enabled by default, but no longer enables selecting by dragging your
finger across text on a touchscreen. Platforms that are optimized for
touchscreens normally use special text-selection handles, which interact
with Qt via QInputMethod. You can opt out of the behavior change by
setting the environment variable
QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR=old.
Task-number: QTBUG-10684
Task-number: QTBUG-38934
Task-number: QTBUG-90494
Task-number: QTBUG-101205
Change-Id: Icbe81e547b1cf8d5e3cc3ed922f12c7b411ca658
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 3ebb3540df9729d336d90225d3b4c1d2ca182e8e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquicktextedit.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpresshandler.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktextarea.cpp | 6 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index ba8d8a1fc4..3bc1db006a 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -3377,7 +3377,7 @@ void QQuickTextEdit::setOldSelectionDefault() setKeepMouseGrab(false); d->control->setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByMouse); d->control->setTouchDragSelectionEnabled(true); - qCDebug(lcTextEdit, "pre-6.4 behavior chosen by import version: selectByMouse defaults false; if enabled, touchscreen acts like a mouse"); + qCDebug(lcTextEdit, "pre-6.4 behavior chosen: selectByMouse defaults false; if enabled, touchscreen acts like a mouse"); } // TODO in 6.7.0: remove the note about versions prior to 6.4 in selectByMouse() documentation diff --git a/src/quicktemplates2/qquickpresshandler.cpp b/src/quicktemplates2/qquickpresshandler.cpp index b1c2208e99..d752bb36f1 100644 --- a/src/quicktemplates2/qquickpresshandler.cpp +++ b/src/quicktemplates2/qquickpresshandler.cpp @@ -20,7 +20,7 @@ void QQuickPressHandler::mousePressEvent(QMouseEvent *event) if (Qt::LeftButton == (event->buttons() & Qt::LeftButton)) { timer.start(QGuiApplication::styleHints()->mousePressAndHoldInterval(), control); delayedMousePressEvent = new QMouseEvent(event->type(), event->position().toPoint(), event->globalPosition().toPoint(), - event->button(), event->buttons(), event->modifiers()); + event->button(), event->buttons(), event->modifiers(), event->pointingDevice()); } else { timer.stop(); } diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 48bdcddb64..0572746d14 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -19,6 +19,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! \qmltype TextArea \inherits TextEdit @@ -509,6 +511,10 @@ QQuickTextArea::QQuickTextArea(QQuickItem *parent) QObjectPrivate::connect(this, &QQuickTextEdit::readOnlyChanged, d, &QQuickTextAreaPrivate::readOnlyChanged); +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) + if (qEnvironmentVariable("QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR") == u"old"_s) + QQuickTextEdit::setOldSelectionDefault(); +#endif } QQuickTextArea::~QQuickTextArea() |