summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmenubar.cpp
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2015-06-10 16:56:27 +0300
committerShawn Rutledge <shawn.rutledge@qt.io>2018-06-25 16:45:07 +0000
commitc5307203f5c0b0e588cc93e70764c090dd4c2ce0 (patch)
tree8772467f0b0498d352a56b64c5b7c3f60fc75557 /src/widgets/widgets/qmenubar.cpp
parente21d1d38564dde337ab60636e28bfe8d5b6e67df (diff)
Fix interaction with the menu bar on touchscreens
Ignore synthesized mouse move events whithout the left mouse button pressed. We receive such mouse move event on touch before the mouse press event, it causes the menu to show and then the subsequent mouse press event closes the menu. Also don't propagate mouse events after closing a popup to another popup, because they may close the latter one. Change-Id: I50a2d9b57da63d33ffe416161a09f1696d65c88f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmenubar.cpp')
-rw-r--r--src/widgets/widgets/qmenubar.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 4758f64c8c..7c4dd896a4 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -1209,8 +1209,15 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
void QMenuBar::mouseMoveEvent(QMouseEvent *e)
{
Q_D(QMenuBar);
- if (!(e->buttons() & Qt::LeftButton))
+ if (!(e->buttons() & Qt::LeftButton)) {
d->mouseDown = false;
+ // We receive mouse move and mouse press on touch.
+ // Mouse move will open the menu and mouse press
+ // will close it, so ignore mouse move.
+ if (e->source() != Qt::MouseEventNotSynthesized)
+ return;
+ }
+
bool popupState = d->popupState || d->mouseDown;
QAction *action = d->actionAt(e->pos());
if ((action && d->isVisible(action)) || !popupState)