From bdf0771a695f144dcd91f0f9a6cc6b81c5763d87 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Wed, 21 Mar 2018 12:28:00 +0100 Subject: Doc: Remove erroneous example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current documentation is not current anymore. Removed faulty example and added link to relevant page for more information. Task-number: QTBUG-67082 Change-Id: Ic2d29ab358b227289480d9986679676048a35821 Reviewed-by: Topi Reiniƶ Reviewed-by: Simon Hausmann --- src/qml/doc/src/javascript/hostenvironment.qdoc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/qml/doc/src/javascript/hostenvironment.qdoc b/src/qml/doc/src/javascript/hostenvironment.qdoc index d11e96df2b..eb40f10065 100644 --- a/src/qml/doc/src/javascript/hostenvironment.qdoc +++ b/src/qml/doc/src/javascript/hostenvironment.qdoc @@ -154,10 +154,11 @@ This restriction exists as the QML environment is not yet fully established. To run code after the environment setup has completed, see \l {JavaScript in Application Startup Code}. -\li The value of \c this is currently undefined in QML in the majority of contexts. +\li The value of \c this is undefined in QML in the majority of contexts. The \c this keyword is supported when binding properties from JavaScript. -In all other situations, the value of +In QML binding expressions, QML signal handlers, and QML declared functions, +\c this refers to the scope object. In all other situations, the value of \c this is undefined in QML. To refer to a specific object, provide an \c id. For example: @@ -168,20 +169,17 @@ Item { function mouseAreaClicked(area) { console.log("Clicked in area at: " + area.x + ", " + area.y); } - // This will not work because this is undefined + // This will pass area to the function MouseArea { - height: 50; width: 200 - onClicked: mouseAreaClicked(this) - } - // This will pass area2 to the function - MouseArea { - id: area2 + id: area y: 50; height: 50; width: 200 - onClicked: mouseAreaClicked(area2) + onClicked: mouseAreaClicked(area) } } \endqml +\sa {Scope and Naming Resolution} + \endlist -- cgit v1.2.3