diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-12-02 05:07:54 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-12-02 05:07:54 (GMT) |
commit | dd0959ed872bf0cda7ad88382abce0c4b20bbdea (patch) | |
tree | cd49820f7f1a796818fb03bd66fc08da6193f3ab /examples | |
parent | f3076897a43c1093ec19d4ea71cf4c923eb7a084 (diff) | |
parent | 14827a4ae7fd531adc802219473d9822e696b982 (diff) | |
download | Qt-dd0959ed872bf0cda7ad88382abce0c4b20bbdea.zip Qt-dd0959ed872bf0cda7ad88382abce0c4b20bbdea.tar.gz Qt-dd0959ed872bf0cda7ad88382abce0c4b20bbdea.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'examples')
-rw-r--r-- | examples/declarative/workerscript/workerscript.js | 16 | ||||
-rw-r--r-- | examples/declarative/workerscript/workerscript.qml | 6 |
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 { |