QWidgetTextControl: allow context menu to open for a QTextEdit with Qt::NoFocus set

Currently a context menu will only open when right-clicking on a text edit that
has input focus. This means that you cannot e.g bring up the context menu
to copy text for a text edit that doesn't accept input focus (but you are
still allowed to select text with the mouse, which feels a bit contradictory).
This is different from how QLineEdit works, and also different compared to how
native applications work, at least after testing on macOS and Ubuntu.

This patch will change this behavior, so that the context menu always open on both
QPlainTextEdit and QTextEdit, even when they don't accept focus.

Task-number: QTBUG-63868
Change-Id: Ibc4cbcc900077546828690ddc958820677211a5a
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
Richard Moe Gustavsen 2017-10-25 11:48:17 +02:00
parent cf3686e2a4
commit 88a8deea86

View File

@ -1887,8 +1887,6 @@ void QWidgetTextControlPrivate::contextMenuEvent(const QPoint &screenPos, const
Q_UNUSED(contextWidget); Q_UNUSED(contextWidget);
#else #else
Q_Q(QWidgetTextControl); Q_Q(QWidgetTextControl);
if (!hasFocus)
return;
QMenu *menu = q->createStandardContextMenu(docPos, contextWidget); QMenu *menu = q->createStandardContextMenu(docPos, contextWidget);
if (!menu) if (!menu)
return; return;