feat: Add context menu to input field and text blocks

This commit is contained in:
Petr Mironychev
2025-10-11 18:35:19 +02:00
parent cac6068ee7
commit 86b52bf858
2 changed files with 74 additions and 2 deletions

View File

@ -18,6 +18,7 @@
*/
import QtQuick
import Qt.labs.platform as Platform
TextEdit {
id: root
@ -27,4 +28,29 @@ TextEdit {
wrapMode: Text.WordWrap
selectionColor: palette.highlight
color: palette.text
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: contextMenu.open()
propagateComposedEvents: true
}
Platform.Menu {
id: contextMenu
Platform.MenuItem {
text: qsTr("Copy")
enabled: root.selectedText.length > 0
onTriggered: root.copy()
}
Platform.MenuSeparator {}
Platform.MenuItem {
text: qsTr("Select All")
enabled: root.text.length > 0
onTriggered: root.selectAll()
}
}
}