aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-08-30 16:48:57 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-09-01 13:27:55 +0200
commite4ba808305952dd313b495f20300ec6e2c3801ac (patch)
tree7b2315bc8504cfbbd81cbe69773b4b1d67507c65 /examples
parent565a7827bb2a7c7af23eade8f3c8809c72f81251 (diff)
Use QMouseEvent instead of QGraphicsSceneMouseEvent
QMouseEvent now supports floating point coordinates, and the graphics scene event is not be available in QtGui anymore. Change-Id: I28ab428a2d00fc1deef55b05c1c545e74838e105 Reviewed-on: http://codereview.qt.nokia.com/3991 Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/text/textselection/textselection.qml81
1 files changed, 1 insertions, 80 deletions
diff --git a/examples/declarative/text/textselection/textselection.qml b/examples/declarative/text/textselection/textselection.qml
index 4b51f4ea53..a25d0df621 100644
--- a/examples/declarative/text/textselection/textselection.qml
+++ b/examples/declarative/text/textselection/textselection.qml
@@ -37,7 +37,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
Rectangle {
id: editor
@@ -105,85 +105,6 @@ Rectangle {
+"<p><b>Click inside the selection</b> to cut/copy/paste/cancel selection."
+"<p>It's too whacky to let you paste if there is no current selection."
- MouseArea {
- property string drag: ""
- property int pressPos
-
- x: -startHandle.width
- y: 0
- width: parent.width+startHandle.width+endHandle.width
- height: parent.height
-
- onPressAndHold: {
- if (editor.state == "") {
- edit.cursorPosition = edit.positionAt(mouse.x+x,mouse.y+y);
- edit.selectWord();
- editor.state = "selection"
- }
- }
-
- onClicked: {
- if (editor.state == "") {
- edit.cursorPosition = edit.positionAt(mouse.x+x,mouse.y+y);
- if (!edit.focus)
- edit.focus = true;
- edit.openSoftwareInputPanel();
- }
- }
-
- function hitHandle(h,x,y) {
- return x>=h.x+flick.contentX && x<h.x+flick.contentX+h.width && y>=h.y+flick.contentY && y<h.y+flick.contentY+h.height
- }
-
- onPressed: {
- if (editor.state == "selection") {
- if (hitHandle(startHandle,mouse.x+x,mouse.y+y)) {
- drag = "start"
- flick.interactive = false
- } else if (hitHandle(endHandle,mouse.x+x,mouse.y+y)) {
- drag = "end"
- flick.interactive = false
- } else {
- var pos = edit.positionAt(mouse.x+x,mouse.y+y);
- if (pos >= edit.selectionStart && pos <= edit.selectionEnd) {
- drag = "selection"
- flick.interactive = false
- } else {
- drag = ""
- flick.interactive = true
- }
- }
- }
- }
-
- onReleased: {
- if (editor.state == "selection") {
- if (drag == "selection") {
- editor.state = "menu"
- }
- drag = ""
- }
- flick.interactive = true
- }
-
- onPositionChanged: {
- if (editor.state == "selection" && drag != "") {
- if (drag == "start") {
- var pos = edit.positionAt(mouse.x+x+startHandle.width/2,mouse.y+y);
- 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);
- var s = edit.selectionStart;
- if (s > pos)
- s = pos;
- edit.select(s,pos);
- }
- }
- }
- }
}
}