summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-05-31 15:45:01 +1000
committerWarwick Allison <warwick.allison@nokia.com>2010-05-31 15:49:01 +1000
commitb8b1e9784583e3b5960b1966328299f8a1bec440 (patch)
tree26b147cdf82bde0b3d97610a8449fcc1599d2246 /examples
parentc00e6b499e89e4b872e9148c5f8a37f9050d9c84 (diff)
Simplify selection setting. Make TextInput more like TextEdit.
By making selectionStart/End read-only, and adding adding select(). Task-number: QTBUG-11056
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/modelviews/webview/content/FieldText.qml2
-rw-r--r--examples/declarative/text/edit/edit.qml16
2 files changed, 9 insertions, 9 deletions
diff --git a/examples/declarative/modelviews/webview/content/FieldText.qml b/examples/declarative/modelviews/webview/content/FieldText.qml
index c9adde575c..17fa4cd51f 100644
--- a/examples/declarative/modelviews/webview/content/FieldText.qml
+++ b/examples/declarative/modelviews/webview/content/FieldText.qml
@@ -161,8 +161,6 @@ Item {
color: "black"
readOnly: false
focus: true
- selectionStart: 0
- selectionEnd: -1
}
PropertyChanges {
target: editRegion
diff --git a/examples/declarative/text/edit/edit.qml b/examples/declarative/text/edit/edit.qml
index 2774739973..0be42e9531 100644
--- a/examples/declarative/text/edit/edit.qml
+++ b/examples/declarative/text/edit/edit.qml
@@ -157,14 +157,16 @@ Rectangle {
if (editor.state == "selection" && drag != "") {
if (drag == "start") {
var pos = edit.positionAt(mouse.x+x+startHandle.width/2,mouse.y+y);
- if (edit.selectionEnd < pos)
- edit.selectionEnd = pos;
- edit.selectionStart = pos;
+ var e = edit.selectionEnd;
+ if (e < pos)
+ e = pos;
+ edit.select(pos,e);
} else if (drag == "end") {
var pos = edit.positionAt(mouse.x+x-endHandle.width/2,mouse.y+y);
- if (edit.selectionStart > pos)
- edit.selectionStart = pos;
- edit.selectionEnd = pos;
+ var s = edit.selectionStart;
+ if (s > pos)
+ s = pos;
+ edit.select(s,pos);
}
}
}
@@ -226,7 +228,7 @@ Rectangle {
height: 16
Text { anchors.centerIn: parent; text: "Deselect" }
MouseArea { anchors.fill: parent;
- onClicked: { edit.cursorPosition = edit.selectionEnd; edit.selectionStart = edit.selectionEnd; editor.state = "" } }
+ onClicked: { edit.cursorPosition = edit.selectionEnd; edit.select(edit.cursorPosition,edit.cursorPosition); editor.state = "" } }
}
}
}