Full clipboard controls for PTextField

This commit is contained in:
Thomas Perl 2014-03-29 09:23:53 +01:00
parent d1e7b2f2c9
commit 77ed27a6a0
2 changed files with 50 additions and 2 deletions

View file

@ -21,6 +21,7 @@
import QtQuick 2.0
import 'common/constants.js' as Constants
import 'icons/icons.js' as Icons
Item {
id: textField
@ -36,15 +37,15 @@ Item {
height: 50 * pgst.scalef
TextInput {
id: textInput
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
right: parent.right
right: clipboardIcon.left
margins: 5 * pgst.scalef
}
color: Constants.colors.text
selectionColor: Constants.colors.background
id: textInput
font.pixelSize: parent.height * 0.7
font.family: placeholder.font.family
focus: true
@ -59,4 +60,50 @@ Item {
color: Constants.colors.placeholder
font.pixelSize: textInput.font.pixelSize
}
IconMenuItem {
id: clipboardIcon
anchors {
right: parent.right
margins: 5 * pgst.scalef
verticalCenter: parent.verticalCenter
}
icon: Icons.paperclip
onClicked: {
pgst.showSelection([
{
label: 'Copy',
callback: function () {
textInput.copy();
}
},
{
label: 'Paste',
callback: function() {
textInput.paste();
}
},
{
label: 'Cut',
callback: function() {
textInput.cut();
}
},
{
label: 'Clear',
callback: function() {
textInput.text = '';
}
},
{
label: 'Select all',
callback: function() {
textInput.selectAll();
}
}
]);
}
}
}

View file

@ -20,3 +20,4 @@ var magnifying_glass = '\ue074';
var cog = '\u2699';
var link = '\ue077';
var vellipsis = '\u22ee';
var paperclip = '\ue08a';