I'm trying to make a mouse selection rectangle.
But Rectangle {}
object can't have negative width & height values.
So it only selects left-to-right & top-to-bottom
:
Rectangle {
id: selectorRectangle
x: 0
y: 0
width: 0
height: 0
color: "#8000abcd"
border.color: "#00fbfb"
}
MouseArea {
anchors.fill: parent
propagateComposedEvents: true
onPressed: {
selectorRectangle.x = mouse.x
selectorRectangle.y = mouse.y
}
onPositionChanged: {
selectorRectangle.width = mouse.x - selectorRectangle.x
selectorRectangle.height = mouse.y - selectorRectangle.y
}
}
How can I achieve it?
Thanks!