summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-12-02 05:02:05 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-12-02 05:02:05 (GMT)
commit9b31dbebb002da3eecd2d2fc2385098fb983c0c2 (patch)
tree72b4cbdc4cf4667dee9d8c6055d002e1d3d305ef /examples
parent17035bd496d35364ff7f49ef9cc86b0a8c48fe1e (diff)
parent14827a4ae7fd531adc802219473d9822e696b982 (diff)
downloadQt-9b31dbebb002da3eecd2d2fc2385098fb983c0c2.zip
Qt-9b31dbebb002da3eecd2d2fc2385098fb983c0c2.tar.gz
Qt-9b31dbebb002da3eecd2d2fc2385098fb983c0c2.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/workerscript/workerscript.js16
-rw-r--r--examples/declarative/workerscript/workerscript.qml6
2 files changed, 19 insertions, 3 deletions
diff --git a/examples/declarative/workerscript/workerscript.js b/examples/declarative/workerscript/workerscript.js
index 060c04a..f76471f 100644
--- a/examples/declarative/workerscript/workerscript.js
+++ b/examples/declarative/workerscript/workerscript.js
@@ -1,5 +1,15 @@
-onmessage = function(message) {
- print ("You clicked the " + message.rectangle + " rectangle.");
- print ("The coordinates were: " + message.x + "," + message.y);
+var lastx = 0;
+var lasty = 0;
+
+WorkerScript.onMessage = function(message) {
+ var ydiff = message.y - lasty;
+ var xdiff = message.x - lastx;
+
+ var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff);
+
+ lastx = message.x;
+ lasty = message.y;
+
+ WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} );
}
diff --git a/examples/declarative/workerscript/workerscript.qml b/examples/declarative/workerscript/workerscript.qml
index 3729022..e36d4d4 100644
--- a/examples/declarative/workerscript/workerscript.qml
+++ b/examples/declarative/workerscript/workerscript.qml
@@ -6,6 +6,12 @@ Rectangle {
WorkerScript {
id: myWorker
source: "workerscript.js"
+
+ onMessage: {
+ print("Moved " + messageObject.xmove + " along the X axis.");
+ print("Moved " + messageObject.ymove + " along the Y axis.");
+ print("Moved " + messageObject.move + " pixels.");
+ }
}
Rectangle {