summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/mouseregion.qml
blob: 683770b8f04db37401ad7c71c255eab728b13d63 (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
import Qt 4.7

Rectangle { width: 200; height: 100
Row {
//! [0]
Rectangle { 
    width: 100; height: 100
    color: "green"

    MouseArea { 
        anchors.fill: parent
        onClicked: { parent.color = 'red' }
    }
}
//! [0]
//! [1]
Rectangle {
    width: 100; height: 100
    color: "green"

    MouseArea {
        anchors.fill: parent
        acceptedButtons: Qt.LeftButton | Qt.RightButton
        onClicked: {
            if (mouse.button == Qt.RightButton)
                parent.color = 'blue';
            else
                parent.color = 'red';
        }
    }
}
//! [1]
}
}