forked from qt-creator/qt-creator
Avoid multiple context menus popping up.
On Mac in debug mode, right-clicking on extra text area would first open the markers menu, and after that the menu where you select which debug widgets to show (like Stack or Locals and Expressions). Opening the markers menu in a context menu event on the extra area is both the more sensible thing to do, and works around the Mac inconsistency. Task-number: QTCREATORBUG-4699 Change-Id: I38efaffac80a98773deeeada3d0e3ef4f872c03b Reviewed-on: http://codereview.qt.nokia.com/2434 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
@@ -145,6 +145,9 @@ protected:
|
||||
void leaveEvent(QEvent *event){
|
||||
textEdit->extraAreaLeaveEvent(event);
|
||||
}
|
||||
void contextMenuEvent(QContextMenuEvent *event) {
|
||||
textEdit->extraAreaContextMenuEvent(event);
|
||||
}
|
||||
|
||||
void wheelEvent(QWheelEvent *event) {
|
||||
QCoreApplication::sendEvent(textEdit->viewport(), event);
|
||||
@@ -4191,6 +4194,19 @@ void BaseTextEditorWidget::extraAreaLeaveEvent(QEvent *)
|
||||
extraAreaMouseEvent(&me);
|
||||
}
|
||||
|
||||
void BaseTextEditorWidget::extraAreaContextMenuEvent(QContextMenuEvent *e)
|
||||
{
|
||||
QTextCursor cursor = cursorForPosition(QPoint(0, e->pos().y()));
|
||||
if (d->m_marksVisible) {
|
||||
QMenu * contextMenu = new QMenu(this);
|
||||
emit editor()->markContextMenuRequested(editor(), cursor.blockNumber() + 1, contextMenu);
|
||||
if (!contextMenu->isEmpty())
|
||||
contextMenu->exec(e->globalPos());
|
||||
delete contextMenu;
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
||||
{
|
||||
QTextCursor cursor = cursorForPosition(QPoint(0, e->pos().y()));
|
||||
@@ -4247,13 +4263,6 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
||||
} else {
|
||||
d->extraAreaToggleMarkBlockNumber = cursor.blockNumber();
|
||||
}
|
||||
} else if (d->m_marksVisible && e->button() == Qt::RightButton) {
|
||||
QMenu * contextMenu = new QMenu(this);
|
||||
emit editor()->markContextMenuRequested(editor(), cursor.blockNumber() + 1, contextMenu);
|
||||
if (!contextMenu->isEmpty())
|
||||
contextMenu->exec(e->globalPos());
|
||||
delete contextMenu;
|
||||
e->accept();
|
||||
}
|
||||
} else if (d->extraAreaSelectionAnchorBlockNumber >= 0) {
|
||||
QTextCursor selection = cursor;
|
||||
|
||||
Reference in New Issue
Block a user