From a4c37d687d41840036f62c8c4659c5fa025c7291 Mon Sep 17 00:00:00 2001 From: DionysusBenstein Date: Sun, 1 Jul 2018 09:40:27 +0300 Subject: [PATCH] Add context menu --- AppBar.qml | 2 +- main.qml | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/AppBar.qml b/AppBar.qml index 6a80fe4..131d9a1 100644 --- a/AppBar.qml +++ b/AppBar.qml @@ -30,7 +30,7 @@ Rectangle { Text { id: headerText - text: "Counter v2.4.5" + text: "Counter v2.5.0" font.family: robotoMediumFont.name font.pointSize: 15 color: "white" diff --git a/main.qml b/main.qml index ee4ecbd..4223b3b 100644 --- a/main.qml +++ b/main.qml @@ -240,6 +240,44 @@ ApplicationWindow { wrapMode: Text.WrapAnywhere placeholderText: qsTr("Введите текст...") selectByMouse: true + anchors.fill: input + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onPressed: mouse.button === Qt.RightButton ? firstContextMenu.popup() : input.forceActiveFocus() + } + + Menu { + id: firstContextMenu + Action { + text: qsTr("Cut") + onTriggered: { + input.cut() + } + } + + Action { + text: qsTr("Copy") + onTriggered: { + input.copy() + } + } + + Action { + text: qsTr("Paste") + onTriggered: { + input.paste() + } + } + + Action { + text: qsTr("Delete") + onTriggered: { + input.deleteLater() + } + } + } } }