diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-09-19 15:19:40 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-09-19 16:36:55 +0000 |
commit | 935974e174d87f9bf10a56d14bb73ade726d827a (patch) | |
tree | 03bfc3f55da39c4c2202c9295a09623400bfdd77 /src/quicktemplates2/qquickabstractbutton.cpp | |
parent | fbe806c544a45c83f091109e04fab5d86620183f (diff) |
Fix Switch to stay pressed as appropriate
Switch is a special type of button that should stay pressed (similarly
to Slider) even if the finger slips outside the bounds of the control.
It was doing that only when dragged from the handle, not when dragged
from the background.
Change-Id: I462c66cfe2e67fc3c95215ffeafe3e5771174418
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickabstractbutton.cpp')
-rw-r--r-- | src/quicktemplates2/qquickabstractbutton.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 220ec102..96adbf9a 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -105,7 +105,7 @@ static const int AUTO_REPEAT_INTERVAL = 100; */ QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate() : - down(false), explicitDown(false), pressed(false), checked(false), checkable(false), + down(false), explicitDown(false), pressed(false), keepPressed(false), checked(false), checkable(false), autoExclusive(false), autoRepeat(false), wasHeld(false), holdTimer(0), delayTimer(0), repeatTimer(0), repeatButton(Qt::NoButton), indicator(nullptr), group(nullptr) { @@ -525,7 +525,7 @@ void QQuickAbstractButton::mouseMoveEvent(QMouseEvent *event) { Q_D(QQuickAbstractButton); QQuickControl::mouseMoveEvent(event); - setPressed(contains(event->pos())); + setPressed(d->keepPressed || contains(event->pos())); if (d->autoRepeat) d->stopPressRepeat(); @@ -540,7 +540,7 @@ void QQuickAbstractButton::mouseReleaseEvent(QMouseEvent *event) bool wasPressed = d->pressed; setPressed(false); - if (contains(event->pos())) + if (d->keepPressed || contains(event->pos())) nextCheckState(); if (wasPressed) { |