Commit a7ffd67a authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

OutputWindow: Activate links only on left button click

Change-Id: I650da02a6f084d1db3be3891a575d4f97df06aef
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent 95b5477c
......@@ -61,7 +61,7 @@ public:
bool enforceNewline = false;
bool scrollToBottom = true;
bool linksActive = true;
bool mousePressed = false;
Qt::MouseButton mouseButtonPressed = Qt::NoButton;
bool m_zoomEnabled = false;
float m_originalFontSize = 0.;
int maxLineCount = 100000;
......@@ -134,15 +134,13 @@ OutputWindow::~OutputWindow()
void OutputWindow::mousePressEvent(QMouseEvent * e)
{
d->mousePressed = true;
d->mouseButtonPressed = e->button();
QPlainTextEdit::mousePressEvent(e);
}
void OutputWindow::mouseReleaseEvent(QMouseEvent *e)
{
d->mousePressed = false;
if (d->linksActive) {
if (d->linksActive && d->mouseButtonPressed == Qt::LeftButton) {
const QString href = anchorAt(e->pos());
if (d->formatter)
d->formatter->handleLink(href);
......@@ -150,6 +148,7 @@ void OutputWindow::mouseReleaseEvent(QMouseEvent *e)
// Mouse was released, activate links again
d->linksActive = true;
d->mouseButtonPressed = Qt::NoButton;
QPlainTextEdit::mouseReleaseEvent(e);
}
......@@ -157,7 +156,7 @@ void OutputWindow::mouseReleaseEvent(QMouseEvent *e)
void OutputWindow::mouseMoveEvent(QMouseEvent *e)
{
// Cursor was dragged to make a selection, deactivate links
if (d->mousePressed && textCursor().hasSelection())
if (d->mouseButtonPressed != Qt::NoButton && textCursor().hasSelection())
d->linksActive = false;
if (!d->linksActive || anchorAt(e->pos()).isEmpty())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment