summaryrefslogtreecommitdiff
path: root/src/controls/qquickpopupwindow.cpp
diff options
context:
space:
mode:
authorFilippo Cucchetto <filippocucchetto@gmail.com>2015-04-12 11:17:34 +0200
committerFilippo Cucchetto <filippocucchetto@gmail.com>2015-04-14 12:03:16 +0000
commit2c1141c62d9cc1043a5b488fdb6b752402fb8553 (patch)
treedcc0d9531329b04c57be03f17df44a1a33d8001c /src/controls/qquickpopupwindow.cpp
parentd9d9dd16da54b6b40c37b8e1e9c2394422835ab0 (diff)
downloadqtquickcontrols-2c1141c62d9cc1043a5b488fdb6b752402fb8553.tar.gz
MenuBar top level menus are not closed on click after being opened
This fix revert partially what was done for resolving QTBUG-40391. Infact the change QTBUG-40391 caused the propagation of the events that caused the dismiss of a popupMenu. This in turn caused this bug where the click that should close menu is forwarded instead of being swallowed. However for supporting the behavior of context menu outside menubar we added some cases where the developer expect to receive the event that dismissed the popup. The use case is to reopen a dismissed popup on right click (see windows right click behavior on right clicks) Task-number: QTBUG-45315 Change-Id: If5a181b65ed9d879521ac20de577510908125169 Reviewed-by: Filippo Cucchetto <filippocucchetto@gmail.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Diffstat (limited to 'src/controls/qquickpopupwindow.cpp')
-rw-r--r--src/controls/qquickpopupwindow.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp
index ec0ab07c..8db73701 100644
--- a/src/controls/qquickpopupwindow.cpp
+++ b/src/controls/qquickpopupwindow.cpp
@@ -178,19 +178,28 @@ void QQuickPopupWindow::mouseReleaseEvent(QMouseEvent *e)
void QQuickPopupWindow::forwardEventToTransientParent(QMouseEvent *e)
{
+ bool forwardEvent = true;
+
if (!qobject_cast<QQuickPopupWindow*>(transientParent())
&& ((m_mouseMoved && e->type() == QEvent::MouseButtonRelease)
|| e->type() == QEvent::MouseButtonPress)) {
// Clicked outside any popup
dismissPopup();
+ forwardEvent = shouldForwardEventAfterDismiss(e);
}
- if (transientParent()) {
+
+ if (forwardEvent && transientParent()) {
QPoint parentPos = transientParent()->mapFromGlobal(mapToGlobal(e->pos()));
QMouseEvent pe = QMouseEvent(e->type(), parentPos, e->button(), e->buttons(), e->modifiers());
QGuiApplication::sendEvent(transientParent(), &pe);
}
}
+bool QQuickPopupWindow::shouldForwardEventAfterDismiss(QMouseEvent*) const
+{
+ return false;
+}
+
void QQuickPopupWindow::exposeEvent(QExposeEvent *e)
{
if (isExposed() && m_needsActivatedEvent) {