Widgets: ignore unhandled right mouse button presses
In many places this was already done; but there was some old code remaining where mousePressEvent() simply returned without ignoring the unhandled event. Task-number: QTBUG-93486 Task-number: QTBUG-132066 Pick-to: 6.9 Change-Id: I4a876980b7ef88ee478fa8cfd9f68b5be5b217a2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
10c844f053
commit
a117525515
@ -1364,6 +1364,7 @@ void QAbstractSpinBox::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
d->keyboardModifiers = event->modifiers();
|
||||
if (event->button() != Qt::LeftButton || d->buttonState != None) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1503,8 +1503,10 @@ void QLineEdit::mousePressEvent(QMouseEvent* e)
|
||||
|
||||
if (d->sendMouseEventToInputContext(e))
|
||||
return;
|
||||
if (e->button() == Qt::RightButton)
|
||||
if (e->button() == Qt::RightButton) {
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
#ifdef QT_KEYPAD_NAVIGATION
|
||||
if (QApplication::QApplicationPrivate() && !hasEditFocus()) {
|
||||
setEditFocus(true);
|
||||
|
@ -536,8 +536,10 @@ void QScrollBar::mousePressEvent(QMouseEvent *e)
|
||||
|
||||
if (d->maximum == d->minimum // no range
|
||||
|| (e->buttons() & (~e->button())) // another button was clicked before
|
||||
|| !(e->button() == Qt::LeftButton || (midButtonAbsPos && e->button() == Qt::MiddleButton)))
|
||||
|| !(e->button() == Qt::LeftButton || (midButtonAbsPos && e->button() == Qt::MiddleButton))) {
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
d->pressedControl = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->position().toPoint(), this);
|
||||
d->pointerOutsidePressedControl = false;
|
||||
|
@ -247,6 +247,7 @@ private slots:
|
||||
void taskQTBUG_4679_selectToStartEndOfBlock();
|
||||
#ifndef QT_NO_CONTEXTMENU
|
||||
void taskQTBUG_7902_contextMenuCrash();
|
||||
void contextMenu();
|
||||
#endif
|
||||
void taskQTBUG_7395_readOnlyShortcut();
|
||||
void QTBUG697_paletteCurrentColorGroup();
|
||||
@ -4025,6 +4026,20 @@ void tst_QLineEdit::taskQTBUG_7902_contextMenuCrash()
|
||||
QTest::qWait(300);
|
||||
// No crash, it's allright.
|
||||
}
|
||||
|
||||
void tst_QLineEdit::contextMenu() // QTBUG-132066
|
||||
{
|
||||
QLineEdit le;
|
||||
le.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&le));
|
||||
|
||||
// right-click: QLineEdit::mousePressEvent() should ignore the mouse press;
|
||||
// QLineEdit::contextMenuEvent() should then be called to create and open a context menu
|
||||
QTest::mouseClick(le.windowHandle(), Qt::RightButton, {}, le.rect().center());
|
||||
QTRY_VERIFY(le.findChild<QMenu *>());
|
||||
|
||||
// This test could be extended to check and activate menu items.
|
||||
}
|
||||
#endif
|
||||
|
||||
void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut()
|
||||
|
Loading…
x
Reference in New Issue
Block a user