/****************************************************************************
**
-** 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)
**
/*!
\qmlclass MouseArea QDeclarative1MouseArea
+ \inqmlmodule QtQuick 1
\ingroup qml-basic-interaction-elements
- \since 4.7
+ \since QtQuick 1.0
\brief The MouseArea item enables simple mouse handling.
\inherits Item
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 MouseArea::onEntered()
+ \qmlsignal QtQuick1::MouseArea::onEntered()
This handler is called when the mouse enters the mouse area.
*/
/*!
- \qmlsignal MouseArea::onExited()
+ \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
*/
/*!
- \qmlsignal MouseArea::onPositionChanged(MouseEvent mouse)
+ \qmlsignal QtQuick1::MouseArea::onPositionChanged(MouseEvent mouse)
This handler is called when the mouse position changes.
*/
/*!
- \qmlsignal MouseArea::onClicked(MouseEvent mouse)
+ \qmlsignal QtQuick1::MouseArea::onClicked(MouseEvent mouse)
This handler is called when there is a click. A click is defined as a press followed by a release,
both inside the MouseArea (pressing, moving outside the MouseArea, and then moving back inside and
*/
/*!
- \qmlsignal MouseArea::onPressed(MouseEvent mouse)
+ \qmlsignal QtQuick1::MouseArea::onPressed(MouseEvent mouse)
This handler is called when there is a press.
The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
*/
/*!
- \qmlsignal MouseArea::onReleased(MouseEvent mouse)
+ \qmlsignal QtQuick1::MouseArea::onReleased(MouseEvent mouse)
This handler is called when there is a release.
The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
*/
/*!
- \qmlsignal MouseArea::onPressAndHold(MouseEvent mouse)
+ \qmlsignal QtQuick1::MouseArea::onPressAndHold(MouseEvent mouse)
This handler is called when there is a long press (currently 800ms).
The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
*/
/*!
- \qmlsignal MouseArea::onDoubleClicked(MouseEvent mouse)
+ \qmlsignal QtQuick1::MouseArea::onDoubleClicked(MouseEvent mouse)
This handler is called when there is a double-click (a press followed by a release followed by a press).
The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
*/
/*!
- \qmlsignal MouseArea::onCanceled()
+ \qmlsignal QtQuick1::MouseArea::onCanceled()
This handler is called when mouse events have been canceled, either because an event was not accepted, or
because another element stole the mouse event handling.
}
/*!
- \qmlproperty real MouseArea::mouseX
- \qmlproperty real MouseArea::mouseY
+ \qmlproperty real QtQuick1::MouseArea::mouseX
+ \qmlproperty real QtQuick1::MouseArea::mouseY
These properties hold the coordinates of the mouse cursor.
If the hoverEnabled property is false then these properties will only be valid
}
/*!
- \qmlproperty bool MouseArea::enabled
+ \qmlproperty bool QtQuick1::MouseArea::enabled
This property holds whether the item accepts mouse events.
By default, this property is true.
}
/*!
- \qmlproperty bool MouseArea::preventStealing
+ \qmlproperty bool QtQuick1::MouseArea::preventStealing
\since Quick 1.1
This property holds whether the mouse events may be stolen from this
MouseArea.
}
/*!
- \qmlproperty MouseButtons MouseArea::pressedButtons
+ \qmlproperty MouseButtons QtQuick1::MouseArea::pressedButtons
This property holds the mouse buttons currently pressed.
It contains a bitwise combination of:
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
*/
}
/*!
- \qmlproperty bool MouseArea::hoverEnabled
+ \qmlproperty bool QtQuick1::MouseArea::hoverEnabled
This property holds whether hover events are handled.
By default, mouse events are only handled in response to a button event, or when a button is
}
/*!
- \qmlproperty bool MouseArea::containsMouse
+ \qmlproperty bool QtQuick1::MouseArea::containsMouse
This property holds whether the mouse is currently inside the mouse area.
\warning This property is not updated if the area moves under the mouse: \e containsMouse will not change.
}
/*!
- \qmlproperty bool MouseArea::pressed
+ \qmlproperty bool QtQuick1::MouseArea::pressed
This property holds whether the mouse area is currently pressed.
*/
bool QDeclarative1MouseArea::pressed() const
}
/*!
- \qmlproperty Qt::MouseButtons MouseArea::acceptedButtons
+ \qmlproperty QtQuick1::Qt::MouseButtons MouseArea::acceptedButtons
This property holds the mouse buttons that the mouse area reacts to.
The available buttons are:
}
/*!
- \qmlproperty Item MouseArea::drag.target
- \qmlproperty bool MouseArea::drag.active
- \qmlproperty enumeration MouseArea::drag.axis
- \qmlproperty real MouseArea::drag.minimumX
- \qmlproperty real MouseArea::drag.maximumX
- \qmlproperty real MouseArea::drag.minimumY
- \qmlproperty real MouseArea::drag.maximumY
- \qmlproperty bool MouseArea::drag.filterChildren
+ \qmlproperty Item QtQuick1::MouseArea::drag.target
+ \qmlproperty bool QtQuick1::MouseArea::drag.active
+ \qmlproperty enumeration QtQuick1::MouseArea::drag.axis
+ \qmlproperty real QtQuick1::MouseArea::drag.minimumX
+ \qmlproperty real QtQuick1::MouseArea::drag.maximumX
+ \qmlproperty real QtQuick1::MouseArea::drag.minimumY
+ \qmlproperty real QtQuick1::MouseArea::drag.maximumY
+ \qmlproperty bool QtQuick1::MouseArea::drag.filterChildren
\c drag provides a convenient way to make an item draggable.
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
*/