Android do not detect the onLeave signal of mouseArea(Qt5.2)



  • mac OS X 10.8.5
    Qt5.2

    tried api 10,14,15,19
    compile with armeabi

    @
    import QtQuick 2.0

    Rectangle {
    width: 360
    height: 360

    MouseArea {
        id: mouseArea
    
        property bool isEnter: false
    
        anchors.fill: parent
        hoverEnabled: true
    
        onEntered: {
            //console.log("enter")
            mouseArea.isEnter = true
        }
    
        onExited: {
            //console.log("exit")
            mouseArea.isEnter = false
        }
    }
    
    Rectangle{
        id: selected
        anchors.fill: parent
        color: mouseArea.isEnter ? Qt.lighter("blue") : "white"
        //visible: styleData.selected
    
        SequentialAnimation {
            running: mouseArea.isEnter; loops: Animation.Infinite
            NumberAnimation { target:selected; property: "opacity"; to: 1.0; duration: 500}
            NumberAnimation { target:selected; property: "opacity"; to: 0.5; duration: 500}
        }
    }
    

    }
    @

    The code work perfectly under mac, but not on android
    Do anyone have the same issue?
    Any workaround could deal with it?
    Thanks



  • This is my guess, in touch screen device. There is no hover function like mouse have in Desktop environment.

    So there will be no mouse in or leave out event because you need to hover mouse pointer in and out of the area to make it happen.



  • [quote author="Fahmy" date="1386916949"]This is my guess, in touch screen device. There is no hover function like mouse have in Desktop environment.

    So there will be no mouse in or leave out event because you need to hover mouse pointer in and out of the area to make it happen.[/quote]

    Thanks, my experiment show that the in event always trigger, but the leave event may or may not trigger.Do you have a workaround to mimic the in and leave event behaviors?



  • Instead of defining your own boolean you can use the "pressed" boolean from the MouseArea:

    @color: mouseArea.pressed ? Qt.lighter("blue") : "white"@

    That should solve your problem.


Log in to reply
 

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