aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/mousearea
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@jollamobile.com>2014-07-11 14:10:49 +1000
committerMartin Jones <martin.jones@jollamobile.com>2014-07-16 07:54:58 +0200
commit112efda64ba24e7d9255a36065223e9800a50c21 (patch)
treec35446169d49b7ab4d4bf9a21b983cbc251206a5 /examples/quick/mousearea
parent427bee6cb616d515ae04bc47193e35e19e1b519e (diff)
Add containsPress property to MouseArea
It is very common to use pressed and containsMouse properties together to highlight a pressed item, e.g. property bool highlighted: pressed && containsMouse The containsPress property allows simplification and optimization of user code. [ChangeLog][QtQuick] Add containsPress property to MouseArea Task-number: QTBUG-40130 Change-Id: Ie286d431154eb37a99e57e4cf881d68d7cbbe31d Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'examples/quick/mousearea')
-rw-r--r--examples/quick/mousearea/doc/src/mousearea.qdoc4
-rw-r--r--examples/quick/mousearea/mousearea.qml4
2 files changed, 6 insertions, 2 deletions
diff --git a/examples/quick/mousearea/doc/src/mousearea.qdoc b/examples/quick/mousearea/doc/src/mousearea.qdoc
index 827e5497ee..b1dd549a8e 100644
--- a/examples/quick/mousearea/doc/src/mousearea.qdoc
+++ b/examples/quick/mousearea/doc/src/mousearea.qdoc
@@ -40,7 +40,9 @@
\section1 MouseArea Behavior
When you click inside the red square, the \l Text type will list several
- properties of that click which are available to QML.
+ properties of that click which are available to QML. The opacity of the
+ red square will be reduced while the mouse is pressed and remains inside
+ the MouseArea.
Signals are emitted by the MouseArea when clicks or other discrete
operations occur within it.
diff --git a/examples/quick/mousearea/mousearea.qml b/examples/quick/mousearea/mousearea.qml
index dac891d729..8958391715 100644
--- a/examples/quick/mousearea/mousearea.qml
+++ b/examples/quick/mousearea/mousearea.qml
@@ -38,7 +38,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.4
Rectangle {
id: box
@@ -49,10 +49,12 @@ Rectangle {
width: 120; height: 120
anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10
color: "red"
+ opacity: redSquareMouseArea.containsPress ? 0.6 : 1.0
Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent }
MouseArea {
+ id: redSquareMouseArea
anchors.fill: parent
hoverEnabled: true
property string buttonID