From 655e19b862e54ad61b7b2fa6d05463382c7baa61 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 14 Sep 2009 18:53:49 +0200 Subject: Fix closing the menu of a QMenuBar with the mouse Ammend commit 41dbc4406 and 21cf7b4c431742 We do not always get the mouseReleaseEvent (because the popups grabs the mouse. So set mouseDown to false in the mouseMoveEvent if no buttons are pressed. We also need to call setCurrentAction(0) in the case we are hovering on the empty area with no popup open. (in otder to remove the highlight) The code is now much closer to the code before the two previous commit Reviewed-by: Prasanth --- src/gui/widgets/qmenubar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 8591a77..7b0f37e 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1252,9 +1252,11 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) void QMenuBar::mouseMoveEvent(QMouseEvent *e) { Q_D(QMenuBar); + if (!(e->buttons() & Qt::LeftButton)) + d->mouseDown = false; bool popupState = d->popupState || d->mouseDown; QAction *action = d->actionAt(e->pos()); - if (action && d->isVisible(action)) + if ((action && d->isVisible(action)) || !popupState) d->setCurrentAction(action, popupState); } -- cgit v0.12