From f3729cac2d0301de5e7091c60f893de8a1249d16 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 28 Aug 2013 14:21:51 +0200 Subject: [PATCH] correctly filter child events --- .../draganddrop/DeclarativeDragArea.cpp | 23 ++++++++++++++++++- .../draganddrop/DeclarativeDragArea.h | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/declarativeimports/draganddrop/DeclarativeDragArea.cpp b/src/declarativeimports/draganddrop/DeclarativeDragArea.cpp index fba25858c..96e646ef2 100644 --- a/src/declarativeimports/draganddrop/DeclarativeDragArea.cpp +++ b/src/declarativeimports/draganddrop/DeclarativeDragArea.cpp @@ -204,6 +204,10 @@ void DeclarativeDragArea::mousePressEvent(QMouseEvent* event) m_draggingJustStarted = true; } +void DeclarativeDragArea::mouseReleaseEvent(QMouseEvent* event) +{ + m_draggingJustStarted = false; +} void DeclarativeDragArea::mouseMoveEvent(QMouseEvent *event) { @@ -305,10 +309,27 @@ bool DeclarativeDragArea::childMouseEventFilter(QQuickItem *item, QEvent *event) return false; } - if (event->type() == QEvent::MouseMove) { + switch (event->type()) { + case QEvent::MouseButtonPress: { + QMouseEvent *me = static_cast(event); + qDebug() << "press in dragarea"; + mousePressEvent(me); + break; + } + case QEvent::MouseMove: { QMouseEvent *me = static_cast(event); qDebug() << "move in dragarea"; mouseMoveEvent(me); + break; + } + case QEvent::MouseButtonRelease: { + QMouseEvent *me = static_cast(event); + qDebug() << "release in dragarea"; + mouseReleaseEvent(me); + break; + } + default: + break; } return QQuickItem::childMouseEventFilter(item, event); diff --git a/src/declarativeimports/draganddrop/DeclarativeDragArea.h b/src/declarativeimports/draganddrop/DeclarativeDragArea.h index ae1875504..661ad4c61 100644 --- a/src/declarativeimports/draganddrop/DeclarativeDragArea.h +++ b/src/declarativeimports/draganddrop/DeclarativeDragArea.h @@ -133,7 +133,7 @@ Q_SIGNALS: protected: void mouseMoveEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *) {} + void mouseReleaseEvent(QMouseEvent *); bool childMouseEventFilter(QQuickItem *item, QEvent *event); private: