QComboBox: Disable wheel events on OS X & iOS

This is follow-up for QTabBar fix ea47d152b3.

In native OS X applications using mouse wheel on combo boxes have absolutely no
effect. We should bring the same behavior to Qt based OS X apps too, as users
are complaining of unexpected behavior, eg. randomly switching Qt Creator
sidebar mode when scrolling file list and moving mouse pointer little bit
above. Moreover inertial mouse behavior on OS X makes combo box usually move
several indexes, rather than single one on slight finger slide.

This also applies to iOS apps so the change affects all Apple platforms.

Task-number: QTBUG-10707
Change-Id: I6582265039198707ad8c2f54de96ee2a0b0e0b47
Reviewed-by: Adam Strzelecki <ono@java.pl>
Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com>
bb10
Adam Strzelecki 2015-11-05 22:35:42 +01:00 committed by Jake Petroules
parent cd0a125123
commit 9daef8a54c
2 changed files with 10 additions and 0 deletions

View File

@ -3238,6 +3238,9 @@ void QComboBox::keyReleaseEvent(QKeyEvent *e)
#ifndef QT_NO_WHEELEVENT
void QComboBox::wheelEvent(QWheelEvent *e)
{
#ifdef Q_OS_DARWIN
Q_UNUSED(e);
#else
Q_D(QComboBox);
if (!d->viewContainer()->isVisible()) {
int newIndex = currentIndex();
@ -3258,6 +3261,7 @@ void QComboBox::wheelEvent(QWheelEvent *e)
}
e->accept();
}
#endif
}
#endif

View File

@ -2044,7 +2044,13 @@ void tst_QComboBox::mouseWheel_data()
QTest::newRow("upper locked") << disabled << start << wheel << expected;
wheel = -1;
#ifdef Q_OS_DARWIN
// on OS X & iOS mouse wheel shall have no effect on combo box
expected = start;
#else
// on other OSes we should jump to next enabled item (no. 5)
expected = 5;
#endif
QTest::newRow("jump over") << disabled << start << wheel << expected;
disabled.clear();