workround for Qt < 5.10 added

This commit is contained in:
Uwe Rathmann 2019-04-04 17:59:17 +02:00
parent ace07bd7dd
commit f681e0e2db

View File

@ -1545,7 +1545,7 @@ bool QskControl::childMouseEventFilter( QQuickItem* item, QEvent* event )
if ( event->type() == QEvent::MouseButtonPress )
{
auto me = static_cast< const QMouseEvent* >( event );
auto me = static_cast< QMouseEvent* >( event );
if ( me->source() == Qt::MouseEventSynthesizedByQt )
{
@ -1554,15 +1554,37 @@ bool QskControl::childMouseEventFilter( QQuickItem* item, QEvent* event )
mouse events. For all versions < 5.10 those events are
passed through childMouseEventFilter without doing the
extra checks, that are done for real mouse events.
Furthermore the coordinates are relative
to this - not to item.
To avoid having a different behavior between using
mouse and touch, we do those checks here.
*/
if ( !( item->acceptedMouseButtons() & me->button() ) )
return false;
const auto pos = item->mapFromScene( me->windowPos() );
if ( !item->contains( pos ) )
return false;
auto itm = item;
auto pos = item->mapFromScene( me->windowPos() );
for ( itm = item; itm != this; itm = itm->parentItem() )
{
if ( itm->acceptedMouseButtons() & me->button() )
{
if ( itm->contains( pos ) )
break;
}
pos += QPointF( itm->x(), itm->y() );
}
if ( itm != item )
{
if ( itm == this )
return false;
QScopedPointer<QMouseEvent> clonedEvent(
QQuickWindowPrivate::cloneMouseEvent( me, &pos ) );
return d_func()->maybeGesture( itm, clonedEvent.data() );
}
}
}