summaryrefslogtreecommitdiffstats
path: root/examples/declarative/workerscript/workerscript.qml
blob: 0566f1f9b20e3008f998e91565c283933fd0f6fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import Qt 4.6

Rectangle {
    width: 480; height: 320;

    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 {
        width: 200; height: 200
        anchors.left: parent.left
        anchors.leftMargin: 20
        color: "red"

        MouseArea { 
            anchors.fill: parent
            onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } );
        }
    }

    Rectangle {
        width: 200; height: 200
        anchors.right: parent.right
        anchors.rightMargin: 20
        color: "blue"

        MouseArea { 
            anchors.fill: parent
            onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } );
        }
    }

    Text {
        text: "Click a Rectangle!"
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 50
    }
}