summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-11-23 12:35:23 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-11-23 12:37:18 (GMT)
commitc275ba17d263f9108ee26e32a0f89b0c57e526e0 (patch)
tree1e6bb5b6c456199eaeb25c5bf029bddf338b9eb8 /src/gui
parentd08fc6843e58c63f1c101462bb2e30166a5dbde9 (diff)
downloadQt-c275ba17d263f9108ee26e32a0f89b0c57e526e0.zip
Qt-c275ba17d263f9108ee26e32a0f89b0c57e526e0.tar.gz
Qt-c275ba17d263f9108ee26e32a0f89b0c57e526e0.tar.bz2
Make the buttons react on mouse release only if it was pressed
Task-number: QTBUG-3521 Reviewed-by: prasanth
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/qabstractbutton.cpp7
-rw-r--r--src/gui/widgets/qabstractbutton_p.h1
2 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp
index cb46791..8834373 100644
--- a/src/gui/widgets/qabstractbutton.cpp
+++ b/src/gui/widgets/qabstractbutton.cpp
@@ -165,7 +165,7 @@ QAbstractButtonPrivate::QAbstractButtonPrivate(QSizePolicy::ControlType type)
shortcutId(0),
#endif
checkable(false), checked(false), autoRepeat(false), autoExclusive(false),
- down(false), blockRefresh(false),
+ down(false), blockRefresh(false), pressed(false),
#ifndef QT_NO_BUTTONGROUP
group(0),
#endif
@@ -1090,6 +1090,7 @@ void QAbstractButton::mousePressEvent(QMouseEvent *e)
}
if (hitButton(e->pos())) {
setDown(true);
+ d->pressed = true;
repaint(); //flush paint event before invoking potentially expensive operation
QApplication::flush();
d->emitPressed();
@@ -1103,6 +1104,8 @@ void QAbstractButton::mousePressEvent(QMouseEvent *e)
void QAbstractButton::mouseReleaseEvent(QMouseEvent *e)
{
Q_D(QAbstractButton);
+ d->pressed = false;
+
if (e->button() != Qt::LeftButton) {
e->ignore();
return;
@@ -1127,7 +1130,7 @@ void QAbstractButton::mouseReleaseEvent(QMouseEvent *e)
void QAbstractButton::mouseMoveEvent(QMouseEvent *e)
{
Q_D(QAbstractButton);
- if (!(e->buttons() & Qt::LeftButton)) {
+ if (!(e->buttons() & Qt::LeftButton) || !d->pressed) {
e->ignore();
return;
}
diff --git a/src/gui/widgets/qabstractbutton_p.h b/src/gui/widgets/qabstractbutton_p.h
index be7c022..d86163b 100644
--- a/src/gui/widgets/qabstractbutton_p.h
+++ b/src/gui/widgets/qabstractbutton_p.h
@@ -77,6 +77,7 @@ public:
uint autoExclusive :1;
uint down :1;
uint blockRefresh :1;
+ uint pressed : 1;
#ifndef QT_NO_BUTTONGROUP
QButtonGroup* group;