Commit 73c32586 authored by David Schulz's avatar David Schulz Committed by Leandro Melo
Browse files

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: default avatarLeandro Melo <leandro.melo@nokia.com>
parent 7a40bd16
...@@ -2622,11 +2622,7 @@ void BaseTextEditorWidget::processTooltipRequest(const QTextCursor &c) ...@@ -2622,11 +2622,7 @@ void BaseTextEditorWidget::processTooltipRequest(const QTextCursor &c)
bool BaseTextEditorWidget::viewportEvent(QEvent *event) bool BaseTextEditorWidget::viewportEvent(QEvent *event)
{ {
d->m_contentsChanged = false; d->m_contentsChanged = false;
if (event->type() == QEvent::ContextMenu) { if (event->type() == QEvent::ToolTip) {
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 (QApplication::keyboardModifiers() & Qt::ControlModifier if (QApplication::keyboardModifiers() & Qt::ControlModifier
|| (!(QApplication::keyboardModifiers() & Qt::ShiftModifier) || (!(QApplication::keyboardModifiers() & Qt::ShiftModifier)
&& d->m_behaviorSettings.m_constrainHoverTooltips)) { && d->m_behaviorSettings.m_constrainHoverTooltips)) {
...@@ -4223,6 +4219,12 @@ void BaseTextEditorWidget::mousePressEvent(QMouseEvent *e) ...@@ -4223,6 +4219,12 @@ void BaseTextEditorWidget::mousePressEvent(QMouseEvent *e)
if (d->m_currentLink.isValid()) if (d->m_currentLink.isValid())
d->m_linkPressed = true; 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 #ifdef Q_OS_LINUX
......
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