correctly filter child events

This commit is contained in:
Marco Martin 2013-08-28 14:21:51 +02:00
parent 314ba53f67
commit f3729cac2d
2 changed files with 23 additions and 2 deletions

View File

@ -204,6 +204,10 @@ void DeclarativeDragArea::mousePressEvent(QMouseEvent* event)
m_draggingJustStarted = true; m_draggingJustStarted = true;
} }
void DeclarativeDragArea::mouseReleaseEvent(QMouseEvent* event)
{
m_draggingJustStarted = false;
}
void DeclarativeDragArea::mouseMoveEvent(QMouseEvent *event) void DeclarativeDragArea::mouseMoveEvent(QMouseEvent *event)
{ {
@ -305,10 +309,27 @@ bool DeclarativeDragArea::childMouseEventFilter(QQuickItem *item, QEvent *event)
return false; return false;
} }
if (event->type() == QEvent::MouseMove) { switch (event->type()) {
case QEvent::MouseButtonPress: {
QMouseEvent *me = static_cast<QMouseEvent *>(event);
qDebug() << "press in dragarea";
mousePressEvent(me);
break;
}
case QEvent::MouseMove: {
QMouseEvent *me = static_cast<QMouseEvent *>(event); QMouseEvent *me = static_cast<QMouseEvent *>(event);
qDebug() << "move in dragarea"; qDebug() << "move in dragarea";
mouseMoveEvent(me); mouseMoveEvent(me);
break;
}
case QEvent::MouseButtonRelease: {
QMouseEvent *me = static_cast<QMouseEvent *>(event);
qDebug() << "release in dragarea";
mouseReleaseEvent(me);
break;
}
default:
break;
} }
return QQuickItem::childMouseEventFilter(item, event); return QQuickItem::childMouseEventFilter(item, event);

View File

@ -133,7 +133,7 @@ Q_SIGNALS:
protected: protected:
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *) {} void mouseReleaseEvent(QMouseEvent *);
bool childMouseEventFilter(QQuickItem *item, QEvent *event); bool childMouseEventFilter(QQuickItem *item, QEvent *event);
private: private: