aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-02-12 13:40:20 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-02-12 13:56:03 +0000
commit572d7011f123324e70dde4c75260f32cd696f709 (patch)
tree8b57b4b19c51bc69aa2bdc15f0a3d1a12e9bd174 /src/templates
parent17614b700e313648839885ae9814e7f62682be88 (diff)
Test and fix AbstractButton::pressAndHold()
Using the same auto test that already exists for TextField and TextArea nicely exposed some difference in the behavior: - the signal wasn't canceled on second press - the signal was canceled right away on any tiny move. now it allows the same little threshold than TextField and TextArea Change-Id: I6b9bd19c614b36dd0ec7b232f821af3aa929d02a Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/templates')
-rw-r--r--src/templates/qquickabstractbutton.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/templates/qquickabstractbutton.cpp b/src/templates/qquickabstractbutton.cpp
index 6aa44cad..95afc09d 100644
--- a/src/templates/qquickabstractbutton.cpp
+++ b/src/templates/qquickabstractbutton.cpp
@@ -122,6 +122,7 @@ void QQuickAbstractButtonPrivate::startPressAndHold()
{
Q_Q(QQuickAbstractButton);
wasHeld = false;
+ stopPressAndHold();
if (isPressAndHoldConnected())
holdTimer = q->startTimer(QGuiApplication::styleHints()->mousePressAndHoldInterval());
}
@@ -515,8 +516,10 @@ void QQuickAbstractButton::mousePressEvent(QMouseEvent *event)
if (d->autoRepeat) {
d->startRepeatDelay();
d->repeatButton = event->button();
- } else {
+ } else if (Qt::LeftButton == (event->buttons() & Qt::LeftButton)) {
d->startPressAndHold();
+ } else {
+ d->stopPressAndHold();
}
}
@@ -528,7 +531,7 @@ void QQuickAbstractButton::mouseMoveEvent(QMouseEvent *event)
if (d->autoRepeat)
d->stopPressRepeat();
- else if (!d->pressed)
+ else if (d->holdTimer > 0 && QLineF(d->pressPoint, event->localPos()).length() > QGuiApplication::styleHints()->startDragDistance())
d->stopPressAndHold();
}