summaryrefslogtreecommitdiffstats
path: root/examples/declarative/mousearea/mouse.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/mousearea/mouse.qml')
-rw-r--r--examples/declarative/mousearea/mouse.qml40
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/declarative/mousearea/mouse.qml b/examples/declarative/mousearea/mouse.qml
new file mode 100644
index 0000000..9191f8a
--- /dev/null
+++ b/examples/declarative/mousearea/mouse.qml
@@ -0,0 +1,40 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 200; height: 200
+ Rectangle {
+ width: 50; height: 50
+ color: "red"
+ Text { text: "Click"; anchors.centerIn: parent }
+ MouseArea {
+ hoverEnabled: true
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onPressed: { console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') }
+ onReleased: { console.log('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') }
+ onClicked: { console.log('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') }
+ onDoubleClicked: { console.log('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') }
+ onPressAndHold: { console.log('press and hold') }
+ onEntered: { console.log('entered ' + pressed) }
+ onExited: { console.log('exited ' + pressed) }
+ anchors.fill: parent
+ }
+ }
+ Rectangle {
+ y: 100; width: 50; height: 50
+ color: "blue"
+ Text { text: "Drag"; anchors.centerIn: parent }
+ MouseArea {
+ drag.target: parent
+ drag.axis: "XAxis"
+ drag.minimumX: 0
+ drag.maximumX: 150
+ onPressed: { console.log('press') }
+ onReleased: { console.log('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') }
+ onClicked: { console.log('click' + '(wasHeld: ' + mouse.wasHeld + ')') }
+ onDoubleClicked: { console.log('double click') }
+ onPressAndHold: { console.log('press and hold') }
+ anchors.fill: parent
+ }
+ }
+}