PDA

View Full Version : MouseArea does not emit onPressed after being cancelled?



elmgreen
20th October 2011, 11:28
Hi all,

I have run into a problem, that I could need some help with :)

I am using an Image element for a button, see snippet below. I have added a MouseArea and its onPressed and onReleased signals control whether the user is "talking". Normally this works fine, but if some event occurs, while the user is pressing the "button", so another element is shown and "steals" the mouse events, onCanceled is emitted from the MouseArea, but thereafter I cannot detect any presses on the image - after the intruding element has been removed. I am pressing the image, but no onPressed signal is emitted?

Am I doing something wrong or have I discovered a bug?

Thanks in advance!

Cheers,
Bo


Image {
id: pttButton

source: "images/PTT_button.png"
opacity: 0.4
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: 15
}
enabled: false
visible: pttButtonShown
MouseArea {
id: pttButtonMouseArea
anchors.fill: parent
onPressed: { console.log("pttButtonMouseArea - onPressed"); thisView.callButtonPressed(); contactSelector.closeCallsList() }
onReleased: { console.log("pttButtonMouseArea - onReleased"); thisView.callButtonReleased() }
onCanceled: console.log("pttButtonMouseArea - onCanceled")
}

states: [
State {
name: "stateCallActive"

when: callManager.haveCurrentCall && !pttButtonMouseArea.presse
PropertyChanges { target: pttButton; opacity: 1.0 }
PropertyChanges { target: pttButton; enabled: true }
},
State {
name: "stateCallActivePressed"
when: callManager.haveCurrentCall && pttButtonMouseArea.pressed
PropertyChanges { target: pttButton; opacity: 0.7 }
PropertyChanges { target: pttButton; enabled: true }
}
]
}

elmgreen
24th October 2011, 15:49
Hi all,

I have now made a small test application, where the problem can be reproduced, please see the attached file. It can be run in the QML Viewer.

If you press the blue "button" and wait 5 seconds, a new "window" is shown and in the console log you can see that the button has been "cancelled". Now press "Acknowledge" to dismiss the new window and then the blue button is not working any more; no signals are sent when you press and release it. It is first after the new window has been displayed and removed again, that the button starts working again.

I found out that the pre-requisite for the problem to occur is, that the rectangle, where the button is located, is disabled (i.e. its "enabled" property is set to false) when the new window is displayed.

To me it seems like a bug? Or can I get around this?

Thanks,
Bo
7030