summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-06-27 18:41:05 +0200
committerJ-P Nurmi <jpnurmi@digia.com>2014-06-30 11:01:55 +0200
commitbc8d549938f700b075846caffb877df87cd2e305 (patch)
tree76448a96c952edc71e8d8fb7144544aec352b308 /src
parentf604ff53453f3b2d3184cea668464ee88dc66a04 (diff)
Add TextField::selectByMouse
Change-Id: Id681a65da1a41718d90d90f1e254c4287f93efbe Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/controls/TextField.qml17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml
index 24f5e5e7f..1a8a3503d 100644
--- a/src/controls/TextField.qml
+++ b/src/controls/TextField.qml
@@ -331,6 +331,17 @@ Control {
Accessible.readOnly: readOnly
/*!
+ \qmlproperty bool TextField::selectByMouse
+ \since QtQuick.Controls 1.3
+
+ This property determines if the user can select the text with the
+ mouse.
+
+ The default value is \c true.
+ */
+ property bool selectByMouse: true
+
+ /*!
\qmlproperty string TextField::selectedText
Provides the text currently selected in the text input.
@@ -589,7 +600,7 @@ Control {
TextInput {
id: textInput
focus: true
- selectByMouse: !cursorHandle.delegate || !selectionHandle.delegate
+ selectByMouse: textfield.selectByMouse && (!cursorHandle.delegate || !selectionHandle.delegate)
selectionColor: __panel ? __panel.selectionColor : "darkred"
selectedTextColor: __panel ? __panel.selectedTextColor : "white"
@@ -678,7 +689,7 @@ Control {
}
onPressAndHold: {
var pos = textInput.positionAt(mouse.x, mouse.y)
- textInput.moveHandles(pos, -1)
+ textInput.moveHandles(pos, textfield.selectByMouse ? -1 : pos)
textInput.activate()
}
}
@@ -688,6 +699,7 @@ Control {
editor: textInput
control: textfield
+ active: textfield.selectByMouse
delegate: __style.selectionHandle
maximum: cursorHandle.position - 1
readonly property real selectionX: textInput.selectionRectangle.x
@@ -711,6 +723,7 @@ Control {
editor: textInput
control: textfield
+ active: textfield.selectByMouse
delegate: __style.cursorHandle
minimum: textInput.hasSelection ? selectionHandle.position + 1 : -1
x: textInput.cursorRectangle.x + textInput.x