summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonardo Sobral Cunha <leo.cunha@nokia.com>2010-05-06 05:48:34 (GMT)
committerLeonardo Sobral Cunha <leo.cunha@nokia.com>2010-05-07 01:02:40 (GMT)
commitd7ef9666e2a3c8d06c5f32b7f47f602b177a74f6 (patch)
treef78aede0ac6e535e7a8301c0f8020b32b4286ffc /src
parent7c945e152c9abd0478bed5a4d251012944d93b44 (diff)
downloadQt-d7ef9666e2a3c8d06c5f32b7f47f602b177a74f6.zip
Qt-d7ef9666e2a3c8d06c5f32b7f47f602b177a74f6.tar.gz
Qt-d7ef9666e2a3c8d06c5f32b7f47f602b177a74f6.tar.bz2
Avoid emitting release when the mouse is ungrabbed
Added an onCanceled signal to mouse area, which is triggered when the mouse area rejects the event (propagates to the nearest mouse area beneath) or some other element steals the mouse grab (flickable, for example). Task-number: QTBUG-10162 Reviewed-by: Michael Brasser
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp19
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p.h1
2 files changed, 17 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index c5a995e..74f2338 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -288,6 +288,17 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate()
*/
/*!
+ \qmlsignal MouseArea::onCanceled()
+
+ This handler is called when the mouse events are canceled, either because the event was not accepted or
+ another element stole the mouse event handling. This signal is for advanced users, it's useful in case there
+ is more than one mouse areas handling input, or when there is a mouse area inside a flickable. In the latter
+ case, if you do some logic on pressed and then start dragging, the flickable will steal the mouse handling
+ from the mouse area. In these cases, to reset the logic when there is no mouse handling anymore, you should
+ use onCanceled, in addition to onReleased.
+*/
+
+/*!
\internal
\class QDeclarativeMouseArea
\brief The QDeclarativeMouseArea class provides a simple mouse handling abstraction for use within Qml.
@@ -562,10 +573,12 @@ bool QDeclarativeMouseArea::sceneEvent(QEvent *event)
// state
d->pressed = false;
setKeepMouseGrab(false);
- QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, false);
- emit released(&me);
+ emit canceled();
emit pressedChanged();
- setHovered(false);
+ if (d->hovered) {
+ d->hovered = false;
+ emit hoveredChanged();
+ }
}
}
return rv;
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
index e3f523b..df77ac6 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
@@ -163,6 +163,7 @@ Q_SIGNALS:
void doubleClicked(QDeclarativeMouseEvent *mouse);
void entered();
void exited();
+ void canceled();
protected:
void setHovered(bool);