File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ T.TextField {
1212 property D .Palette placeholderTextPalette: DS .Style .edit .placeholderText
1313 placeholderTextColor: D .ColorSelector .placeholderTextPalette
1414 property alias backgroundColor: panel .backgroundColor
15+ property bool canCopy: control .selectedText .length && control .echoMode === TextInput .Normal
16+ property bool canCut: ! control .readonly && control .selectedText .length && control .echoMode === TextInput .Normal
1517 // alert control properties
1618 property alias alertText: panel .alertText
1719 property alias alertDuration: panel .alertDuration
@@ -77,14 +79,14 @@ T.TextField {
7779 {
7880 text: qsTr (" Copy" )
7981 onTriggered: control .copy ()
80- enabled: control . selectedText . length && control . echoMode === TextInput . Normal
82+ enabled: canCopy
8183 }
8284
8385 MenuItem
8486 {
8587 text: qsTr (" Cut" )
8688 onTriggered: control .cut ()
87- enabled: ! control . readonly && control . selectedText . length && control . echoMode === TextInput . Normal
89+ enabled: canCut
8890 }
8991
9092 MenuItem
@@ -116,4 +118,18 @@ T.TextField {
116118 }
117119 }
118120
121+ Keys .enabled : ! canCopy || ! canCut
122+ Keys .onPressed : function (event ) {
123+ if (event .matches (StandardKey .Copy )) {
124+ if (! canCopy) {
125+ event .accepted = true
126+ return
127+ }
128+ } else if (event .matches (StandardKey .Cut )) {
129+ if (! canCut) {
130+ event .accepted = true
131+ return
132+ }
133+ }
134+ }
119135}
You can’t perform that action at this time.
0 commit comments