summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Pasion <jerome.pasion@nokia.com>2011-02-16 12:10:29 (GMT)
committerJerome Pasion <jerome.pasion@nokia.com>2011-02-16 12:10:29 (GMT)
commite2ae6a38ce2739cee52b7cae9198ca45e315c0cd (patch)
treebb9d89f462372a7beec77d803f7f42ff6ea10514
parent024e657219e86934fbbff94598744d59a234c204 (diff)
downloadQt-e2ae6a38ce2739cee52b7cae9198ca45e315c0cd.zip
Qt-e2ae6a38ce2739cee52b7cae9198ca45e315c0cd.tar.gz
Qt-e2ae6a38ce2739cee52b7cae9198ca45e315c0cd.tar.bz2
Added new snippet code.
Task-number: QTBUG-16071
-rw-r--r--doc/src/declarative/mouseevents.qdoc5
-rw-r--r--doc/src/snippets/declarative/mousearea/mousearea-snippet.qml55
2 files changed, 54 insertions, 6 deletions
diff --git a/doc/src/declarative/mouseevents.qdoc b/doc/src/declarative/mouseevents.qdoc
index eed3a3a..533f64b 100644
--- a/doc/src/declarative/mouseevents.qdoc
+++ b/doc/src/declarative/mouseevents.qdoc
@@ -57,7 +57,7 @@ to define this area is to anchor the \c MouseArea to its parent's area using the
component), then the MouseArea will fill the area defined by the parent's
dimensions. Alternatively, an area smaller or larger than the parent is
definable.
-\snippet doc/src/snippets/declarative/mouse.qml anchor fill
+\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml anchor fill
\section1 Receiving Events
@@ -79,7 +79,7 @@ gestures in greater detail.
\endlist
These signals have signal handlers that are invoked when the signals are emitted.
-\snippet doc/src/snippets/declarative/mouse.qml mouse handlers
+\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml mouse handlers
\section1 Enabling Gestures
Some mouse gestures and button clicks need to be enabled before they send or
@@ -97,6 +97,7 @@ positioning even when there are no mouse button presses. Setting the
\c hoverEnabled property to \c true, in turn will enable the \c entered,
\c exited, and \c positionChanged signal and their respective signal handlers.
+\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml enable handlers
Additionally, to disable the whole mouse area, set the \c MouseArea
element's \c enabled property to \c false.
diff --git a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml b/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml
index 3c2e143..99cdc8b 100644
--- a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml
+++ b/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml
@@ -41,13 +41,60 @@
//! [document]
import QtQuick 1.0
-Rectangle {
- width: 100; height: 100
+//! [parent begin]
+Rectangle {
+//! [parent begin]
+ width: 500; height: 500
color: "green"
- MouseArea {
+Column {
+//! [anchor fill]
+Rectangle {
+ id: button
+ width: 100; height: 100
+
+ MouseArea {
anchors.fill: parent
- onClicked: { parent.color = 'red' }
+ onClicked: console.log("button clicked")
+ }
+ MouseArea {
+ width:150; height: 75
+ onClicked: console.log("irregular area clicked")
+ }
+}
+//! [anchor fill]
+
+Rectangle {
+ id: button
+ width: 100; height: 100
+
+//! [enable handlers]
+ MouseArea {
+ hoverEnabled: true
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onEntered: console.log("mouse entered the area")
+ onExited: console.log("mouse left the area")
}
+//! [enable handlers]
+}
+
+Rectangle {
+ id: button
+ width: 100; height: 100
+
+//! [mouse handlers]
+ MouseArea {
+ anchors.fill: parent
+ onClicked: console.log("area clicked")
+ onDoubleClicked: console.log("area double clicked")
+ onEntered: console.log("mouse entered the area")
+ onExited: console.log("mouse left the area")
+ }
+//! [mouse handlers]
+}
+
+} //end of column
+//! [parent end]
}
+//! [parent end]
//! [document]