Editor: deselect text on contextmenuevent if...

... the event was raised on a position outside of the selection

Task-number: QTCREATORBUG-6734
Change-Id: Ida4ede1e5e7c118799212a1a6cf4766eec969b4a
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
This commit is contained in:
David Schulz
2012-02-08 13:09:04 +01:00
committed by Leandro Melo
parent 7a40bd1682
commit 73c3258683

View File

@@ -2622,11 +2622,7 @@ void BaseTextEditorWidget::processTooltipRequest(const QTextCursor &c)
bool BaseTextEditorWidget::viewportEvent(QEvent *event)
{
d->m_contentsChanged = false;
if (event->type() == QEvent::ContextMenu) {
const QContextMenuEvent *ce = static_cast<QContextMenuEvent*>(event);
if (ce->reason() == QContextMenuEvent::Mouse && !textCursor().hasSelection())
setTextCursor(cursorForPosition(ce->pos()));
} else if (event->type() == QEvent::ToolTip) {
if (event->type() == QEvent::ToolTip) {
if (QApplication::keyboardModifiers() & Qt::ControlModifier
|| (!(QApplication::keyboardModifiers() & Qt::ShiftModifier)
&& d->m_behaviorSettings.m_constrainHoverTooltips)) {
@@ -4223,6 +4219,12 @@ void BaseTextEditorWidget::mousePressEvent(QMouseEvent *e)
if (d->m_currentLink.isValid())
d->m_linkPressed = true;
}
} else if (e->button() == Qt::RightButton) {
int eventCursorPosition = cursorForPosition(e->pos()).position();
if (eventCursorPosition < textCursor().selectionStart()
|| eventCursorPosition > textCursor().selectionEnd()) {
setTextCursor(cursorForPosition(e->pos()));
}
}
#ifdef Q_OS_LINUX