aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-11-18 16:32:25 +0100
committerLiang Qi <liang.qi@qt.io>2019-11-26 11:59:43 +0000
commitb3de744dba87fd8d5c2bdb9ed4c56a3e5455188b (patch)
tree7ef6f858219f52442f92dd112c2441b3c14406d0 /src
parent8ecc00ff54d987ddd8cfbd45a9f2a5bfe18aad80 (diff)
mouseDrag(): ensure that intermediate moves are done for all drags
The code checking if the intermediate move distance was less than the drag threshold, but without accounting for negative distances. Since the negative distances were naturally less than the drag threshold, the intermediate distances were set to zero and the intermediate moves were never done. In practice, this means that mouseDrag() never did intermediate moves (i.e. what happens during a drag in real life) for drags that go from right to left or upwards. Task-number: QTBUG-80152 Change-Id: Ic27021f5ce5ba2937e95fb2dfb532bd2136f4205 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit fad8ef3e4133538e3785d7067c35c652bc894711) Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/imports/testlib/TestCase.qml18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index fff375b49a..20c5ce6418 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -1417,12 +1417,12 @@ Item {
// Divide dx and dy to have intermediate mouseMove while dragging
// Fractions of dx/dy need be superior to the dragThreshold
// to make the drag works though
- var ddx = Math.round(dx/3)
- if (ddx < (util.dragThreshold + 1))
- ddx = 0
- var ddy = Math.round(dy/3)
- if (ddy < (util.dragThreshold + 1))
- ddy = 0
+ var intermediateDx = Math.round(dx/3)
+ if (Math.abs(intermediateDx) < (util.dragThreshold + 1))
+ intermediateDx = 0
+ var intermediateDy = Math.round(dy/3)
+ if (Math.abs(intermediateDy) < (util.dragThreshold + 1))
+ intermediateDy = 0
mousePress(item, x, y, button, modifiers, delay)
@@ -1431,9 +1431,9 @@ Item {
var dragTriggerXDistance = dx > 0 ? (util.dragThreshold + 1) : 0
var dragTriggerYDistance = dy > 0 ? (util.dragThreshold + 1) : 0
mouseMove(item, x + dragTriggerXDistance, y + dragTriggerYDistance, moveDelay, button)
- if (ddx > 0 || ddy > 0) {
- mouseMove(item, x + ddx, y + ddy, moveDelay, button)
- mouseMove(item, x + 2*ddx, y + 2*ddy, moveDelay, button)
+ if (intermediateDx !== 0 || intermediateDy !== 0) {
+ mouseMove(item, x + intermediateDx, y + intermediateDy, moveDelay, button)
+ mouseMove(item, x + 2*intermediateDx, y + 2*intermediateDy, moveDelay, button)
}
mouseMove(item, x + dx, y + dy, moveDelay, button)
mouseRelease(item, x + dx, y + dy, button, modifiers, delay)