summaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-07-27 00:30:07 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-07-27 00:30:07 (GMT)
commitb4b0bdda668e9845623995c788d88a774dd52d98 (patch)
treea39b54275bde034b9cb091c66050fe61ed36162a /doc/src
parent47769726d3d8db03153acfcd9552fd9bc0535358 (diff)
downloadQt-b4b0bdda668e9845623995c788d88a774dd52d98.zip
Qt-b4b0bdda668e9845623995c788d88a774dd52d98.tar.gz
Qt-b4b0bdda668e9845623995c788d88a774dd52d98.tar.bz2
Document 'this' as undefined in QML
Task-number: QTBUG-12396 Reviewed-by: Aaron Kennedy
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/declarative/javascriptblocks.qdoc25
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc
index c41e38e..18da3d2 100644
--- a/doc/src/declarative/javascriptblocks.qdoc
+++ b/doc/src/declarative/javascriptblocks.qdoc
@@ -236,6 +236,31 @@ This restriction exists as the QML environment is not yet fully established.
To run code after the environment setup has completed, refer to
\l {Running JavaScript at Startup}.
+\o The value of \c this is currently undefined in QML
+
+The value of \c this is undefined in QML. To refer to any element, provide
+an \c id. For example:
+
+\qml
+Item {
+ width: 200; height: 100
+ function mouseAreaClicked(area) {
+ console.log("Clicked in area at: " + area.x + ", " + area.y);
+ }
+ // This will not work because this is undefined
+ MouseArea {
+ height: 50; width: 200
+ onClicked: mouseAreaClicked(this)
+ }
+ // This will pass area2 to the function
+ MouseArea {
+ id: area2
+ y: 50; height: 50; width: 200
+ onClicked: mouseAreaClicked(area2)
+ }
+}
+\endqml
+
\endlist
*/