Swallow wheel events while a popup widget is open.
Wheel events should not cause a popup widget parented on a scrollable widget to be closed or moved to correctly reflect the system behavior on OS X and Windows. Task-number: QTBUG-42731 Task-number: QTBUG-40656 Change-Id: I4ef75aa8331390309c251316ac76db2cf9ec51f7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
be5cfa960b
commit
ea9a366d3f
@ -3320,12 +3320,10 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
|||||||
QWidget* w = static_cast<QWidget *>(receiver);
|
QWidget* w = static_cast<QWidget *>(receiver);
|
||||||
QWheelEvent* wheel = static_cast<QWheelEvent*>(e);
|
QWheelEvent* wheel = static_cast<QWheelEvent*>(e);
|
||||||
|
|
||||||
// QTBUG-40656, combo and other popups should close when the main window gets a wheel event.
|
// QTBUG-40656, QTBUG-42731: ignore wheel events when a popup (QComboBox) is open.
|
||||||
while (QWidget *popup = QApplication::activePopupWidget()) {
|
if (const QWidget *popup = QApplication::activePopupWidget()) {
|
||||||
if (w->window() != popup)
|
if (w->window() != popup)
|
||||||
popup->close();
|
return true;
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint relpos = wheel->pos();
|
QPoint relpos = wheel->pos();
|
||||||
|
@ -124,7 +124,7 @@ private slots:
|
|||||||
void pixmapIcon();
|
void pixmapIcon();
|
||||||
void mouseWheel_data();
|
void mouseWheel_data();
|
||||||
void mouseWheel();
|
void mouseWheel();
|
||||||
void wheelClosingPopup();
|
void popupWheelHandling();
|
||||||
void layoutDirection();
|
void layoutDirection();
|
||||||
void itemListPosition();
|
void itemListPosition();
|
||||||
void separatorItem_data();
|
void separatorItem_data();
|
||||||
@ -2037,9 +2037,9 @@ void tst_QComboBox::mouseWheel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QComboBox::wheelClosingPopup()
|
void tst_QComboBox::popupWheelHandling()
|
||||||
{
|
{
|
||||||
// QTBUG-40656, combo and other popups should close when the main window gets a wheel event.
|
// QTBUG-40656, QTBUG-42731 combo and other popups should not be affected by wheel events.
|
||||||
QScrollArea scrollArea;
|
QScrollArea scrollArea;
|
||||||
scrollArea.move(300, 300);
|
scrollArea.move(300, 300);
|
||||||
QWidget *widget = new QWidget;
|
QWidget *widget = new QWidget;
|
||||||
@ -2058,9 +2058,12 @@ void tst_QComboBox::wheelClosingPopup()
|
|||||||
QVERIFY(QTest::qWaitForWindowExposed(&scrollArea));
|
QVERIFY(QTest::qWaitForWindowExposed(&scrollArea));
|
||||||
comboBox->showPopup();
|
comboBox->showPopup();
|
||||||
QTRY_VERIFY(comboBox->view() && comboBox->view()->isVisible());
|
QTRY_VERIFY(comboBox->view() && comboBox->view()->isVisible());
|
||||||
|
const QPoint popupPos = comboBox->view()->pos();
|
||||||
QWheelEvent event(QPointF(10, 10), WHEEL_DELTA, Qt::NoButton, Qt::NoModifier);
|
QWheelEvent event(QPointF(10, 10), WHEEL_DELTA, Qt::NoButton, Qt::NoModifier);
|
||||||
QVERIFY(QCoreApplication::sendEvent(scrollArea.windowHandle(), &event));
|
QVERIFY(QCoreApplication::sendEvent(scrollArea.windowHandle(), &event));
|
||||||
QTRY_VERIFY(!comboBox->view()->isVisible());
|
QCoreApplication::processEvents();
|
||||||
|
QVERIFY(comboBox->view()->isVisible());
|
||||||
|
QCOMPARE(comboBox->view()->pos(), popupPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QComboBox::layoutDirection()
|
void tst_QComboBox::layoutDirection()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user