summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-03 15:20:16 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-03 16:09:02 (GMT)
commit2076f150995e541308b1d8da936b3e12ab68b886 (patch)
treed5b6a6135803b31ec48af83d5a679e379b15257f
parent3d5ffba1a183bbe3d930158e87f65f858b78559c (diff)
downloadQt-2076f150995e541308b1d8da936b3e12ab68b886.zip
Qt-2076f150995e541308b1d8da936b3e12ab68b886.tar.gz
Qt-2076f150995e541308b1d8da936b3e12ab68b886.tar.bz2
Fixed "Hightlighted menu items not always selected" bug.
Menu paintEvent was not called when the mouse cursor lied between the menu item area and the menu frame border. Task-number: 258920 Reviewed-by: olivier
-rw-r--r--src/gui/widgets/qmenu.cpp2
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp36
2 files changed, 37 insertions, 1 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 8eec0fc..0b85eec 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -2721,7 +2721,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e)
QAction *action = d->actionAt(e->pos());
if (!action) {
- if (d->hasHadMouse && !rect().contains(e->pos()))
+ if (d->hasHadMouse)
d->setCurrentAction(0);
return;
} else if(e->buttons()) {
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 1d19ffa..ec9c7b4 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -95,6 +95,7 @@ private slots:
void task250673_activeMultiColumnSubMenuPosition();
void task256918_setFont();
void menuSizeHint();
+ void task258920_mouseBorder();
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
@@ -763,5 +764,40 @@ void tst_QMenu::menuSizeHint()
QCOMPARE(resSize, menu.sizeHint());
}
+class Menu258920 : public QMenu
+{
+ Q_OBJECT
+public slots:
+ void paintEvent(QPaintEvent *e)
+ {
+ QMenu::paintEvent(e);
+ painted = true;
+ }
+
+public:
+ bool painted;
+};
+
+void tst_QMenu::task258920_mouseBorder()
+{
+ Menu258920 menu;
+ QAction *action = menu.addAction("test");
+
+ menu.popup(QPoint());
+ QTest::qWait(100);
+ QRect actionRect = menu.actionGeometry(action);
+ QTest::mouseMove(&menu, actionRect.center());
+ QTest::qWait(30);
+ QTest::mouseMove(&menu, actionRect.center() + QPoint(10, 0));
+ QTest::qWait(30);
+ QCOMPARE(action, menu.activeAction());
+ menu.painted = false;
+ QTest::mouseMove(&menu, QPoint(actionRect.center().x(), actionRect.bottom() + 1));
+ QTest::qWait(30);
+ QCOMPARE(static_cast<QAction*>(0), menu.activeAction());
+ QVERIFY(menu.painted);
+}
+
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"