diff options
author | Matthias Rauter <matthias.rauter@qt.io> | 2023-02-23 12:33:27 +0100 |
---|---|---|
committer | Matthias Rauter <matthias.rauter@qt.io> | 2023-03-09 17:48:36 +0100 |
commit | d3c181356399a6948906d36119a8e50e140090e7 (patch) | |
tree | ce7a0229e72044300086dedc74f4035d3903e368 /src/quick/handlers | |
parent | 065b146dff48d076d39a5af105f2a30051b60260 (diff) |
Don't emit doubleTapped when the buttons are different
A left-click followed by right-click was interpreted as a double-click.
This is different from what I am used to and different
from what I expect. This patch changes the behavior such that only
clicks of the same button are interpreted as double click.
Pick-to: 6.2 6.4 6.5 6.5.0
Fixes: QTBUG-111557
Change-Id: Id0d83ca66944497710d8f659ed5a6d1e4260a2d9
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/handlers')
-rw-r--r-- | src/quick/handlers/qquicktaphandler.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp index 1515e8a6b7..20711819d3 100644 --- a/src/quick/handlers/qquicktaphandler.cpp +++ b/src/quick/handlers/qquicktaphandler.cpp @@ -379,12 +379,16 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QPointerEvent *event, const qreal ts = event->timestamp() / 1000.0; const qreal interval = ts - m_lastTapTimestamp; const auto distanceSquared = QVector2D(point.scenePosition() - m_lastTapPos).lengthSquared(); - if (interval < m_multiTapInterval && distanceSquared < + const auto singleTapReleasedButton = event->isSinglePointEvent() ? static_cast<QSinglePointEvent *>(event)->button() : Qt::NoButton; + if ((interval < m_multiTapInterval && distanceSquared < (event->device()->type() == QInputDevice::DeviceType::Mouse ? m_mouseMultiClickDistanceSquared : m_touchMultiTapDistanceSquared)) + && m_singleTapReleasedButton == singleTapReleasedButton) { ++m_tapCount; - else + } else { + m_singleTapReleasedButton = singleTapReleasedButton; m_tapCount = 1; + } qCDebug(lcTapHandler) << objectName() << "tapped" << m_tapCount << "times; interval since last:" << interval << "sec; distance since last:" << qSqrt(distanceSquared); auto button = event->isSinglePointEvent() ? static_cast<QSinglePointEvent *>(event)->button() : Qt::NoButton; @@ -447,8 +451,8 @@ void QQuickTapHandler::updateTimeHeld() \readonly The number of taps which have occurred within the time and space - constraints to be considered a single gesture. For example, to detect - a triple-tap, you can write: + constraints to be considered a single gesture. The counter is reset to 1 + if the button changed. For example, to detect a triple-tap, you can write: \qml Rectangle { |