diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-04-16 06:50:27 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-04-19 00:20:18 (GMT) |
commit | 5efb732bc78e15605ac9d9f770e1bd24c01bb778 (patch) | |
tree | 952639777368bcdfd444415d9890cf1403d0ec3b /tests/auto/declarative/qdeclarativemousearea/data | |
parent | 465f4df8ad4be9485c37ecc379c45e758b2842ad (diff) | |
download | Qt-5efb732bc78e15605ac9d9f770e1bd24c01bb778.zip Qt-5efb732bc78e15605ac9d9f770e1bd24c01bb778.tar.gz Qt-5efb732bc78e15605ac9d9f770e1bd24c01bb778.tar.bz2 |
Update mouse area coordinates automatically when changing position
Mouse area coordinates are now updated when the mouse area changes position
and positionChanged signals are not emitted on mousePress anymore (only
mousePosChanged signals).
Task-number: QTBUG-9716
Reviewed-by: Michael Brasser
Diffstat (limited to 'tests/auto/declarative/qdeclarativemousearea/data')
-rw-r--r-- | tests/auto/declarative/qdeclarativemousearea/data/updateMousePosOnResize.qml | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativemousearea/data/updateMousePosOnResize.qml b/tests/auto/declarative/qdeclarativemousearea/data/updateMousePosOnResize.qml new file mode 100644 index 0000000..138c25a --- /dev/null +++ b/tests/auto/declarative/qdeclarativemousearea/data/updateMousePosOnResize.qml @@ -0,0 +1,38 @@ +import Qt 4.6 + +Rectangle { + color: "#ffffff" + width: 320; height: 240 + Rectangle { + id: brother + objectName: "brother" + color: "lightgreen" + x: 200; y: 100 + width: 120; height: 120 + } + MouseArea { + id: mouseRegion + objectName: "mouseregion" + + property int x1 + property int y1 + property int x2 + property int y2 + property bool emitPositionChanged: false + property bool mouseMatchesPos: true + + anchors.fill: brother + onPressed: { + if (mouse.x != mouseX || mouse.y != mouseY) + mouseMatchesPos = false + x1 = mouseX; y1 = mouseY + anchors.fill = parent + } + onPositionChanged: { emitPositionChanged = true } + onMousePosChanged: { + if (mouse.x != mouseX || mouse.y != mouseY) + mouseMatchesPos = false + x2 = mouseX; y2 = mouseY + } + } +} |