workaround for wrong calls of childMouseEventFilter ( Qt < 5.10 )

This commit is contained in:
Uwe Rathmann 2019-03-07 13:20:48 +01:00
parent 422fb816bc
commit 63ee61879d

View File

@ -1541,6 +1541,33 @@ bool QskControl::event( QEvent* event )
bool QskControl::childMouseEventFilter( QQuickItem* item, QEvent* event )
{
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
if ( event->type() == QEvent::MouseButtonPress )
{
auto me = static_cast< const QMouseEvent* >( event );
if ( me->source() == Qt::MouseEventSynthesizedByQt )
{
/*
Unhandled touch events result in creating synthetic
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.
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;
}
}
#endif
return d_func()->maybeGesture( item, event );
}