add position listen
This commit is contained in:
parent
057c7aa3ef
commit
a0a6ebf50d
@ -9,16 +9,30 @@ ApplicationWindow {
|
|||||||
title: qsTr("Scroll")
|
title: qsTr("Scroll")
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: 200; height: 200
|
anchors.fill: parent
|
||||||
color: "red"
|
|
||||||
|
|
||||||
Drag.active: dragArea.drag.active
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
|
||||||
MouseArea {
|
width: 200; height: 200
|
||||||
id: dragArea
|
color: "red"
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
drag.target: parent
|
Drag.active: dragArea.drag.active
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: dragArea
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
drag.target: parent
|
||||||
|
|
||||||
|
onPositionChanged: {
|
||||||
|
var positionToParent = mapToItem(root.parent, mouse.x, mouse.y)
|
||||||
|
var positionToRoot = mapToItem(root, mouse.x, mouse.y)
|
||||||
|
console.log(positionToParent, positionToRoot)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,15 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
drag.target: parent
|
drag.target: parent
|
||||||
|
|
||||||
|
onPositionChanged: {
|
||||||
|
let positionToRootParent = mapToItem(root.parent, mouse.x, mouse.y)
|
||||||
|
let positionToRoot = mapToItem(root, mouse.x, mouse.y)
|
||||||
|
let xDiff = positionToRootParent.x - positionToRoot.x
|
||||||
|
let yDiff = positionToRootParent.y - positionToRoot.y
|
||||||
|
|
||||||
|
console.log(tag, uuid + " onPositionChanged: " + xDiff + ", " + yDiff)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property var shadowColor
|
property var shadowColor
|
||||||
|
Reference in New Issue
Block a user