From 85ecc44eee3eb8112faf9989570664ed9302073f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sun, 4 Jan 2015 23:49:17 +0100 Subject: Add missing QPlainTextEdit::createStandardContextMenu(QPoint) [ChangeLog][QtWidgets] Added QPlainTextEdit::createStandardContextMenu(QPoint) overload that takes the position in document coordinates. This method enables the actions that are sensitive to the given position eg. where the user clicked. Change-Id: I47ed7a1afc4fcfb3318c9b7af37867aeb7f2aa35 Reviewed-by: Marc Mutz --- src/widgets/widgets/qplaintextedit.cpp | 21 ++++++++++++++++++++- src/widgets/widgets/qplaintextedit.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src/widgets/widgets') diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 010c837ea0..93c9ddc285 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -2331,9 +2331,12 @@ void QPlainTextEdit::zoomInF(float range) #ifndef QT_NO_CONTEXTMENU /*! This function creates the standard context menu which is shown - when the user clicks on the line edit with the right mouse + when the user clicks on the text edit with the right mouse button. It is called from the default contextMenuEvent() handler. The popup menu's ownership is transferred to the caller. + + We recommend that you use the createStandardContextMenu(QPoint) version instead + which will enable the actions that are sensitive to where the user clicked. */ QMenu *QPlainTextEdit::createStandardContextMenu() @@ -2341,6 +2344,22 @@ QMenu *QPlainTextEdit::createStandardContextMenu() Q_D(QPlainTextEdit); return d->control->createStandardContextMenu(QPointF(), this); } + +/*! + \since 5.5 + This function creates the standard context menu which is shown + when the user clicks on the text edit with the right mouse + button. It is called from the default contextMenuEvent() handler + and it takes the \a position in document coordinates where the mouse click was. + This can enable actions that are sensitive to the position where the user clicked. + The popup menu's ownership is transferred to the caller. +*/ + +QMenu *QPlainTextEdit::createStandardContextMenu(const QPoint &position) +{ + Q_D(QPlainTextEdit); + return d->control->createStandardContextMenu(position, this); +} #endif // QT_NO_CONTEXTMENU /*! diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h index 2e9b619558..69bd2ab647 100644 --- a/src/widgets/widgets/qplaintextedit.h +++ b/src/widgets/widgets/qplaintextedit.h @@ -149,6 +149,7 @@ public: virtual QVariant loadResource(int type, const QUrl &name); #ifndef QT_NO_CONTEXTMENU QMenu *createStandardContextMenu(); + QMenu *createStandardContextMenu(const QPoint &position); #endif QTextCursor cursorForPosition(const QPoint &pos) const; -- cgit v1.2.3