diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-07-27 00:30:07 (GMT) |
---|---|---|
committer | Toby Tomkins <toby.tomkins@nokia.com> | 2010-07-28 06:15:28 (GMT) |
commit | e50db476e3fb32a68ea3cceab8198ef47613d88a (patch) | |
tree | d9f5bf5fd34bea5499c333973b9eadc0b2f467b7 /doc | |
parent | 3a2a18d64f96f54522869495eba33935374c1f1e (diff) | |
download | Qt-e50db476e3fb32a68ea3cceab8198ef47613d88a.zip Qt-e50db476e3fb32a68ea3cceab8198ef47613d88a.tar.gz Qt-e50db476e3fb32a68ea3cceab8198ef47613d88a.tar.bz2 |
Document 'this' as undefined in QML
Task-number: QTBUG-12396
Reviewed-by: Aaron Kennedy
(cherry picked from commit b4b0bdda668e9845623995c788d88a774dd52d98)
Diffstat (limited to 'doc')
-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 */ |