MouseArea: Pressed and hover at the same time?



  • Hi,

    There is a little thing that I absolutely need for the application I am developping: I have to be able of dragging an object onto another one and at least one of them should notice that they are intersecting.
    So, the point is that one of the items must accept the onEntered signal even though the mouse is pressed form outside.

    For example:
    @
    import QtQuick 1.0

    Rectangle{
    id: base
    width: 500
    height: 500
    MouseArea{ //Even without this mousearea I don't get what i want.
    anchors.fill: parent
    //onPressed:{console.log("big")}
    }

    Rectangle{
      id: t
      width: 100
       height: 100
       color: "red"
       MouseArea{
          anchors.fill: parent 
          hoverEnabled: true
          onPressed:{console.log("little-press")}
          onEntered:{console.log("little-enter")}
          drag.target: t
        }
     }
    

    }
    @

    What I wnat is to press the moue button outside the red square, and move it without releasing the button. When the mouse passes over the red rectangle, I want the signal onEntered to be emitted. I don't understang why it is not emited because onEntered should only care about the mouse beeing inside the mouseArea, not about the buttons.

    Any idea of how to do it? (It is quite important for what i'm developping...)

    Thank you very much.





  • and, there is no solution? Did I understand the bugreport well?....
    well, I'll something different then...



  • It mentions QT-1099 in some internal Nokia system in 2010. Well, that does not sound very positive. I personally could use this in one my project.



  • Well, finally I did it differnetly and it works.
    I post here the "algorithmic" soultion in my case (it may help someone)
    I wanted to get when I was intersecting with a line while I was dragging a rectangle, so what I did was:
    @
    Rectangle{
    id: dragged
    MouseArea{
    drag.target: dragged
    onPositionChanged:{
    for each line I may intercept{
    d = distance(line, mouseX,mouseY) //This gives me the line from (mouseX,mouseY) to the line
    if(d < line.width){
    //it means I'm on the line while dragging the rectangle.
    }
    }
    }
    }
    }
    @

    well, thank you again for the quick answer ;)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.