summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/state.qml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets/declarative/state.qml')
-rw-r--r--doc/src/snippets/declarative/state.qml21
1 files changed, 7 insertions, 14 deletions
diff --git a/doc/src/snippets/declarative/state.qml b/doc/src/snippets/declarative/state.qml
index a99c2e2..ce2653b 100644
--- a/doc/src/snippets/declarative/state.qml
+++ b/doc/src/snippets/declarative/state.qml
@@ -46,24 +46,17 @@ Rectangle {
width: 100; height: 100
color: "black"
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: myRect.state == 'clicked' ? myRect.state = "" : myRect.state = 'clicked';
+ }
+
states: [
State {
name: "clicked"
- PropertyChanges {
- target: myRect
- color: "red"
- }
+ PropertyChanges { target: myRect; color: "red" }
}
]
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (myRect.state == "") // i.e. the default state
- myRect.state = "clicked";
- else
- myRect.state = "";
- }
- }
}
//![0]