Mouse Realease behavior...
-
@
import QtQuick 1.0Item {
width: 200
height: 100Rectangle { id: rect1 width: parent.width / 2 height: parent.height anchors.left: parent.left color: "blue" MouseArea { anchors.fill: parent onPressed: { console.log ("rect1 pressed" + " mouse x = " + mouseX + " mouse y = " + mouseY) } onReleased: { console.log ("rect1 released" + " mouse x = " + mouseX + " mouse y = " + mouseY) } } } Rectangle { id: rect2 width: parent.width / 2 height: parent.height anchors.right: parent.right color: "yellow" MouseArea { anchors.fill: parent onPressed: { console.log ("rect2 pressed" + " mouse x = " + mouseX + " mouse y = " + mouseY) } onReleased: { console.log ("rect2 released" + " mouse x = " + mouseX + " mouse y = " + mouseY) } } }
}
@Hello,
I wrote the above code, in which i am receiving a little strange behavior (for me, at least).
I have two rectangles each contains mouse area with mouse pressed and mouse released slots.
now if I press mouse in first rectangle, slot of mouse pressed of first rectangle gets call.
but if i hold the press and release mouse in second rectangle still first rectangle receives mouse release event and its slot gets call.
is this proper behavior.? as i was expecting mouse release event to be received from other rectangle. -
Hello,
actually the mouseReleased event happen on the object where the press was done.
if you want to detect if the mouse is outside the element pressed
you can for example use this
@Rectangle{
id : idTX
anchor.fill:.....
MouseArea{
onMousePositionChanged:
{
if( mouse != null)
{
var okX = mouse.x > 0 && mouse.x < idTX.width
var okY = mouse.y > 0 && mouse.y < idTX.heightif( !(okX && okY ) ) {/*here you are outside*/} } } }
}@
Edit :
could use onExit of mousearea!