diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-07-27 00:30:07 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-07-27 00:30:07 (GMT) |
commit | b4b0bdda668e9845623995c788d88a774dd52d98 (patch) | |
tree | a39b54275bde034b9cb091c66050fe61ed36162a /doc/src/declarative | |
parent | 47769726d3d8db03153acfcd9552fd9bc0535358 (diff) | |
download | Qt-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/declarative')
-rw-r--r-- | doc/src/declarative/javascriptblocks.qdoc | 25 |
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 */ |