Add a ShowContextMenu action

Allow users without physical MenuKey to open the context menu

Change-Id: Id886a5614e26d614cba6ceb3b08a9df6148e9655
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Jesus Fernandez
2017-06-01 17:15:35 +02:00
committed by Jesus Fernandez
parent 9a0eca15c5
commit f3cd5cdb7e
4 changed files with 19 additions and 0 deletions

View File

@@ -1323,6 +1323,13 @@ void TextEditorWidget::selectWordUnderCursor()
setTextCursor(tc);
}
void TextEditorWidget::showContextMenu()
{
QTextCursor tc = textCursor();
const QPoint cursorPos = mapToGlobal(cursorRect(tc).bottomRight() + QPoint(1,1));
qGuiApp->postEvent(this, new QContextMenuEvent(QContextMenuEvent::Keyboard, cursorPos));
}
void TextEditorWidget::copyLineUp()
{
d->copyLineUpDown(true);