From 88f837465f55ffb68a2e5fefb1aff307c771c21c Mon Sep 17 00:00:00 2001 From: NIRMAL MANOJ C Date: Sat, 11 Jul 2020 11:24:16 +0530 Subject: [PATCH] Intercept right-click event in the decompiler widget (#2281) Update cursor before opening context menu for right-click --- src/widgets/DecompilerWidget.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/widgets/DecompilerWidget.cpp b/src/widgets/DecompilerWidget.cpp index d2173704..e34c3f92 100644 --- a/src/widgets/DecompilerWidget.cpp +++ b/src/widgets/DecompilerWidget.cpp @@ -435,13 +435,18 @@ bool DecompilerWidget::eventFilter(QObject *obj, QEvent *event) if (event->type() == QEvent::MouseButtonDblClick && (obj == ui->textEdit || obj == ui->textEdit->viewport())) { QMouseEvent *mouseEvent = static_cast(event); - - const QTextCursor &cursor = ui->textEdit->cursorForPosition(QPoint(mouseEvent->x(), - mouseEvent->y())); + ui->textEdit->setTextCursor(ui->textEdit->cursorForPosition(mouseEvent->pos())); seekToReference(); return true; } - + if (event->type() == QEvent::MouseButtonPress + && (obj == ui->textEdit || obj == ui->textEdit->viewport())) { + QMouseEvent *mouseEvent = static_cast(event); + if (mouseEvent->button() == Qt::RightButton) { + ui->textEdit->setTextCursor(ui->textEdit->cursorForPosition(mouseEvent->pos())); + return true; + } + } return MemoryDockWidget::eventFilter(obj, event); }