Commit db5f2f14 authored by Eike Ziller's avatar Eike Ziller

Text editors: Do not show tool tip for empty area

The editors were showing tool tips for the last cursor position in a
line, even if the mouse was hovered over the empty space behind the
line.

Task-number: QTCREATORBUG-9437
Change-Id: Ibe3b0140b73c3a15811eeaf50a15d75f378f37f4
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 714d56a3
...@@ -2517,8 +2517,17 @@ bool BaseTextEditorWidget::viewportEvent(QEvent *event) ...@@ -2517,8 +2517,17 @@ bool BaseTextEditorWidget::viewportEvent(QEvent *event)
return true; return true;
} }
processTooltipRequest(cursorForPosition(pos)); QTextCursor tc = cursorForPosition(pos);
return true; QTextBlock block = tc.block();
QTextLine line = block.layout()->lineForTextPosition(tc.positionInBlock());
QTC_CHECK(line.isValid());
// Only handle tool tip for text cursor if mouse is within the block for the text cursor,
// and not if the mouse is e.g. in the empty space behind a short line.
if (line.isValid()
&& pos.x() <= blockBoundingGeometry(block).left() + line.naturalTextRect().right()) {
processTooltipRequest(tc);
return true;
}
} }
return QPlainTextEdit::viewportEvent(event); return QPlainTextEdit::viewportEvent(event);
} }
......
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