diff options
author | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2010-06-23 17:13:58 (GMT) |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2010-06-30 15:55:17 (GMT) |
commit | bed06332190147b4061a563aedcbf103ae155830 (patch) | |
tree | e553d73ca755ed737f121b87e54a61ebe11c018a | |
parent | f6cd0264c6e6f0bdb451e4f44284372e32e1db91 (diff) | |
download | Qt-bed06332190147b4061a563aedcbf103ae155830.zip Qt-bed06332190147b4061a563aedcbf103ae155830.tar.gz Qt-bed06332190147b4061a563aedcbf103ae155830.tar.bz2 |
QGraphicsView: Handle wheelEvents correctly with Qt::Popup widgets.
This fixes an issue in QtWebKit where scrolling with the wheel while
a combo box is opened cause the page to scroll while the popup don't
move. This patch either ignore the event on Mac or close the popup on
other platforms.
Reviewed-by: Yoann Lopes
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index b821551..e5264da 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4162,6 +4162,25 @@ void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent) wheelEvent->scenePos(), wheelEvent->widget()); +#ifdef Q_WS_MAC + // On Mac, ignore the event if the first item under the mouse is not the last opened + // popup (or one of its descendant) + if (!d->popupWidgets.isEmpty() && !wheelCandidates.isEmpty() && wheelCandidates.first() != d->popupWidgets.back() && !d->popupWidgets.back()->isAncestorOf(wheelCandidates.first())) { + wheelEvent->accept(); + return; + } +#else + // Find the first popup under the mouse (including the popup's descendants) starting from the last. + // Remove all popups after the one found, or all or them if no popup is under the mouse. + // Then continue with the event. + QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.end(); + while (--iter >= d->popupWidgets.begin() && !wheelCandidates.isEmpty()) { + if (wheelCandidates.first() == *iter || (*iter)->isAncestorOf(wheelCandidates.first())) + break; + d->removePopup(*iter); + } +#endif + bool hasSetFocus = false; foreach (QGraphicsItem *item, wheelCandidates) { if (!hasSetFocus && item->isEnabled() |