forked from qt-creator/qt-creator
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:
committed by
Leandro Melo
parent
7a40bd1682
commit
73c3258683
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user