diff options
-rw-r--r-- | src/controls/qquickmenupopupwindow.cpp | 14 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 14 |
2 files changed, 23 insertions, 5 deletions
diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp index 2a91940e..a578ea62 100644 --- a/src/controls/qquickmenupopupwindow.cpp +++ b/src/controls/qquickmenupopupwindow.cpp @@ -184,11 +184,15 @@ QQuickMenuBar *QQuickMenuPopupWindow::menuBar() const bool QQuickMenuPopupWindow::shouldForwardEventAfterDismiss(QMouseEvent *e) const { - // The events that dismissed a popup child of a menu contained in the menubar - // are never forwarded - if (QQuickMenuBar *mb = menuBar()) { - QPoint parentPos = transientParent()->mapFromGlobal(mapToGlobal(e->pos())); - if (!mb->isNative() && mb->contentItem()->contains(parentPos)) + // If the event falls inside this item the event should not be forwarded. + // For example for comboboxes or top menus of the menubar + QQuickMenuBar *mb = menuBar(); + QQuickItem *item = mb && !mb->isNative() ? mb->contentItem() : menu()->visualItem(); + QWindow *window = transientParent(); + if (item && window && item->window() == window) { + QPointF pos = window->mapFromGlobal(mapToGlobal(e->pos())); + pos = item->mapFromScene(pos); + if (item->contains(pos)) return false; } diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index cecc3928..7db9a75e 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -774,5 +774,19 @@ TestCase { compare(comboBox.currentText, "Pomegranate") comboBox.destroy() } + + function test_qtBug44532() { + if (Qt.platform.os === "osx") + skip("When the menu pops up on OS X, it does not return and the test fails after time out") + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.2 ; ComboBox { model: ["A", "BB", "CCCCC"] }', container, '') + var popup = comboBox.__popup + verify(popup) + tryCompare(popup, "__popupVisible", false) + mouseClick(comboBox) + tryCompare(popup, "__popupVisible", true) + mouseClick(comboBox) + tryCompare(popup, "__popupVisible", false) + comboBox.destroy() + } } } |