diff --git a/qt6/src/qml/TextField.qml b/qt6/src/qml/TextField.qml index b0789328..a438f5f6 100644 --- a/qt6/src/qml/TextField.qml +++ b/qt6/src/qml/TextField.qml @@ -54,4 +54,59 @@ T.TextField { implicitWidth: DS.Style.edit.width implicitHeight: DS.Style.edit.textFieldHeight } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton + + onClicked: { + contextMenu.popup(mouse.x, mouse.y) + } + } + + Menu { + id: contextMenu + + MenuItem + { + text: qsTr("Copy") + onTriggered: control.copy() + enabled: control.selectedText.length + } + + MenuItem + { + text: qsTr("Cut") + onTriggered: control.cut() + enabled: control.selectedText.length + } + + MenuItem + { + text: qsTr("Paste") + onTriggered: control.paste() + } + + MenuItem + { + text: qsTr("Select All") + onTriggered: control.selectAll() + enabled: control.text.length + } + + MenuItem + { + text: qsTr("Undo") + onTriggered: control.undo() + enabled: control.canUndo + } + + MenuItem + { + text: qsTr("Redo") + onTriggered: control.redo() + enabled: control.canRedo + } + } + } diff --git a/src/qml/TextField.qml b/src/qml/TextField.qml index 08ce9970..3f12f06b 100644 --- a/src/qml/TextField.qml +++ b/src/qml/TextField.qml @@ -53,4 +53,59 @@ T.TextField { implicitWidth: DS.Style.edit.width implicitHeight: DS.Style.edit.textFieldHeight } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton + + onClicked: { + contextMenu.popup(mouse.x, mouse.y) + } + } + + Menu { + id: contextMenu + + MenuItem + { + text: qsTr("Copy") + onTriggered: control.copy() + enabled: control.selectedText.length + } + + MenuItem + { + text: qsTr("Cut") + onTriggered: control.cut() + enabled: control.selectedText.length + } + + MenuItem + { + text: qsTr("Paste") + onTriggered: control.paste() + } + + MenuItem + { + text: qsTr("Select All") + onTriggered: control.selectAll() + enabled: control.text.length + } + + MenuItem + { + text: qsTr("Undo") + onTriggered: control.undo() + enabled: control.canUndo + } + + MenuItem + { + text: qsTr("Redo") + onTriggered: control.redo() + enabled: control.canRedo + } + } + }