diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-05-31 05:45:01 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-05-31 05:49:01 (GMT) |
commit | b8b1e9784583e3b5960b1966328299f8a1bec440 (patch) | |
tree | 26b147cdf82bde0b3d97610a8449fcc1599d2246 /examples/declarative/text | |
parent | c00e6b499e89e4b872e9148c5f8a37f9050d9c84 (diff) | |
download | Qt-b8b1e9784583e3b5960b1966328299f8a1bec440.zip Qt-b8b1e9784583e3b5960b1966328299f8a1bec440.tar.gz Qt-b8b1e9784583e3b5960b1966328299f8a1bec440.tar.bz2 |
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/declarative/text')
-rw-r--r-- | examples/declarative/text/edit/edit.qml | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/examples/declarative/text/edit/edit.qml b/examples/declarative/text/edit/edit.qml index 2774739..0be42e9 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 = "" } } } } } |