Ignore child event types we're not explicitly interested in.
MouseEventListener listens to both child events and events passing through itself; child events are recorded so the handler for the latter can perform a comparison and avoid emitting signals for the same event again. However, this comparison could fail because the member used to record the last child event would also be updated for events we were not actually interested in. A real-world example of this is opening a popup menu in repsonse to a Press event. This causes an Ungrab event on the child, which would cause the comparison to fail and mousePressEvent to announce the same press yet again. CCBUG:323067
This commit is contained in:
parent
b690e612cc
commit
4d5bac5f22
@ -170,10 +170,9 @@ bool MouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *event)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lastEvent = event;
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::MouseButtonPress: {
|
||||
m_lastEvent = event;
|
||||
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
||||
//the parent will receive events in its own coordinates
|
||||
const QPointF myPos = item->mapToItem(this, me->pos());
|
||||
@ -187,6 +186,7 @@ bool MouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *event)
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseMove: {
|
||||
m_lastEvent = event;
|
||||
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
||||
const QPointF myPos = item->mapToItem(this, me->pos());
|
||||
KDeclarativeMouseEvent dme(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers());
|
||||
@ -196,6 +196,7 @@ bool MouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *event)
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonRelease: {
|
||||
m_lastEvent = event;
|
||||
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
||||
const QPointF myPos = item->mapToItem(this, me->pos());
|
||||
KDeclarativeMouseEvent dme(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers());
|
||||
@ -210,6 +211,7 @@ bool MouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *event)
|
||||
break;
|
||||
}
|
||||
case QEvent::Wheel: {
|
||||
m_lastEvent = event;
|
||||
QWheelEvent *we = static_cast<QWheelEvent *>(event);
|
||||
KDeclarativeWheelEvent dwe(we->pos(), we->globalPos(), we->delta(), we->buttons(), we->modifiers(), we->orientation());
|
||||
emit wheelMoved(&dwe);
|
||||
|
Loading…
x
Reference in New Issue
Block a user