diff --git a/misc/DtkDeclarativeConfig.cmake.in b/misc/DtkDeclarativeConfig.cmake.in index e8aea894..d6b330fb 100644 --- a/misc/DtkDeclarativeConfig.cmake.in +++ b/misc/DtkDeclarativeConfig.cmake.in @@ -7,8 +7,8 @@ find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS Quick REQUIRED ) -include(${CMAKE_CURRENT_LIST_DIR}/Dtk@DTK_VERSION_MAJOR@DeclarativePropertiesTargets.cmake) include(${CMAKE_CURRENT_LIST_DIR}/Dtk@DTK_VERSION_MAJOR@DeclarativeTargets.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/Dtk@DTK_VERSION_MAJOR@DeclarativePropertiesTargets.cmake) set(DTK_QML_APP_PLUGIN_PATH @DTK_QML_APP_PLUGIN_PATH@) get_target_property(DtkDeclarative_INCLUDE_DIRS Dtk@DTK_VERSION_MAJOR@::Declarative INTERFACE_INCLUDE_DIRECTORIES) get_target_property(DtkDeclarative_LIBRARY_DIRS Dtk@DTK_VERSION_MAJOR@::Declarative INTERFACE_LINK_DIRECTORIES) diff --git a/qt6/src/qml/TextField.qml b/qt6/src/qml/TextField.qml index b0789328..d3a56a80 100644 --- a/qt6/src/qml/TextField.qml +++ b/qt6/src/qml/TextField.qml @@ -54,4 +54,63 @@ 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: + { + var text = control.paste() + control.insert(control.cursorPosition, text) + } + } + + 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..38d682e1 100644 --- a/src/qml/TextField.qml +++ b/src/qml/TextField.qml @@ -53,4 +53,63 @@ 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: "Copy" + onTriggered: control.copy() + enabled: control.selectedText.length + } + + MenuItem + { + text: "Cut" + onTriggered: control.cut() + enabled: control.selectedText.length + } + + MenuItem + { + text: "Paste" + onTriggered: + { + var text = control.paste() + control.insert(control.cursorPosition, text) + } + } + + MenuItem + { + text: "Select All" + onTriggered: control.selectAll() + enabled: control.text.length + } + + MenuItem + { + text: "Undo" + onTriggered: control.undo() + enabled: control.canUndo + } + + MenuItem + { + text: "Redo" + onTriggered: control.redo() + enabled: control.canRedo + } + } + }