summaryrefslogtreecommitdiff
path: root/src/controls/qquickpopupwindow.cpp
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-03-23 09:52:08 +0100
committerMichal Klocek <michal.klocek@theqtcompany.com>2015-06-01 06:36:50 +0000
commit6138e25290908372620e9d2ae70893b1b7ae3e08 (patch)
treed05d66e7161bf4df5e0d1585889a956361db4590 /src/controls/qquickpopupwindow.cpp
parent5430a8345938cb747591a69a8a3785c4ee11cd57 (diff)
downloadqtquickcontrols-6138e25290908372620e9d2ae70893b1b7ae3e08.tar.gz
Dismiss a popup window when touch occurs outside
QQuickWindow synthesizes mouse events only for touch points which occur inside the window. This did not work correctly for popup windows, which expect a mouse press outside the window to dismiss the popup. The workaround is to specifically wait for a TouchBegin outside the popup to dismiss it. Task-number: QTBUG-45079 Change-Id: I232220a3fe48c3193299a6a8313a6b9010dd4a53 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/controls/qquickpopupwindow.cpp')
-rw-r--r--src/controls/qquickpopupwindow.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp
index 8db73701..08407e2d 100644
--- a/src/controls/qquickpopupwindow.cpp
+++ b/src/controls/qquickpopupwindow.cpp
@@ -223,4 +223,27 @@ void QQuickPopupWindow::hideEvent(QHideEvent *e)
QQuickWindow::hideEvent(e);
}
+ /*! \reimp */
+bool QQuickPopupWindow::event(QEvent *event)
+{
+ //QTBUG-45079
+ //This is a workaround for popup menu not being closed when using touch input.
+ //Currently mouse synthesized events are not created for touch events which are
+ //outside the qquickwindow.
+
+ if (event->type() == QEvent::TouchBegin && !qobject_cast<QQuickPopupWindow*>(transientParent())) {
+ QRect rect = QRect(QPoint(), size());
+ QTouchEvent *touch = static_cast<QTouchEvent*>(event);
+ QTouchEvent::TouchPoint point = touch->touchPoints().first();
+ if ((point.state() == Qt::TouchPointPressed) && !rect.contains(point.pos().toPoint())) {
+ //first default handling
+ bool result = QQuickWindow::event(event);
+ //now specific broken case
+ if (!m_dismissed)
+ dismissPopup();
+ return result;
+ }
+ }
+ return QQuickWindow::event(event);
+}
QT_END_NAMESPACE