forked from qt-creator/qt-creator
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: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -2517,8 +2517,17 @@ bool BaseTextEditorWidget::viewportEvent(QEvent *event)
|
||||
return true;
|
||||
}
|
||||
|
||||
processTooltipRequest(cursorForPosition(pos));
|
||||
return true;
|
||||
QTextCursor tc = cursorForPosition(pos);
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user