/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
The following example uses a MouseArea in a \l Rectangle that changes
the \l Rectangle color to red when clicked:
- \snippet doc/src/snippets/declarative/mousearea/mousearea.qml import
+ \snippet doc/src/snippets/qtquick1/mousearea/mousearea.qml import
\codeline
- \snippet doc/src/snippets/declarative/mousearea/mousearea.qml intro
+ \snippet doc/src/snippets/qtquick1/mousearea/mousearea.qml intro
\clearfloat
Many MouseArea signals pass a \l{MouseEvent}{mouse} parameter that contains
Here is an extension of the previous example that produces a different
color when the area is right clicked:
- \snippet doc/src/snippets/declarative/mousearea/mousearea.qml intro-extended
+ \snippet doc/src/snippets/qtquick1/mousearea/mousearea.qml intro-extended
\sa MouseEvent, {declarative/touchinteraction/mousearea}{MouseArea example}
*/
/*!
\qmlsignal QtQuick1::MouseArea::onExited()
- This handler is called when the mouse exists the mouse area.
+ This handler is called when the mouse exits the mouse area.
By default the onExited handler is only called while a button is
pressed. Setting hoverEnabled to true enables handling of
onExited when no mouse button is pressed.
+ The example below shows a fairly typical relationship between
+ two MouseAreas, with \c mouseArea2 on top of \c mouseArea1. Moving the
+ mouse into \c mouseArea2 from \c mouseArea1 will cause \c onExited
+ to be called for \c mouseArea1.
+ \qml
+ Rectangle {
+ width: 400; height: 400
+ MouseArea {
+ id: mouseArea1
+ anchors.fill: parent
+ hoverEnabled: true
+ }
+ MouseArea {
+ id: mouseArea2
+ width: 100; height: 100
+ anchors.centerIn: parent
+ hoverEnabled: true
+ }
+ }
+ \endqml
+
+ If instead you give the two mouseAreas a parent-child relationship,
+ moving the mouse into \c mouseArea2 from \c mouseArea1 will \b not
+ cause \c onExited to be called for \c mouseArea1. Instead, they will
+ both be considered to be simultaneously hovered.
+
\sa hoverEnabled
*/
The code below displays "right" when the right mouse buttons is pressed:
- \snippet doc/src/snippets/declarative/mousearea/mousearea.qml mousebuttons
+ \snippet doc/src/snippets/qtquick1/mousearea/mousearea.qml mousebuttons
\sa acceptedButtons
*/
The following example displays a \l Rectangle that can be dragged along the X-axis. The opacity
of the rectangle is reduced when it is dragged to the right.
- \snippet doc/src/snippets/declarative/mousearea/mousearea.qml drag
+ \snippet doc/src/snippets/qtquick1/mousearea/mousearea.qml drag
\note Items cannot be dragged if they are anchored for the requested
\c drag.axis. For example, if \c anchors.left or \c anchors.right was set
If \c drag.filterChildren is set to true, a drag can override descendant MouseAreas. This
enables a parent MouseArea to handle drags, for example, while descendants handle clicks:
- \snippet doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml dragfilter
+ \snippet doc/src/snippets/qtquick1/mousearea/mouseareadragfilter.qml dragfilter
*/