Results 1 to 2 of 2

Thread: MouseArea does not emit onPressed after being cancelled?

  1. #1
    Join Date
    May 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Question MouseArea does not emit onPressed after being cancelled?

    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

    Qt Code:
    1. Image {
    2. id: pttButton
    3.  
    4. source: "images/PTT_button.png"
    5. opacity: 0.4
    6. anchors {
    7. horizontalCenter: parent.horizontalCenter
    8. bottom: parent.bottom
    9. bottomMargin: 15
    10. }
    11. enabled: false
    12. visible: pttButtonShown
    13. MouseArea {
    14. id: pttButtonMouseArea
    15. anchors.fill: parent
    16. onPressed: { console.log("pttButtonMouseArea - onPressed"); thisView.callButtonPressed(); contactSelector.closeCallsList() }
    17. onReleased: { console.log("pttButtonMouseArea - onReleased"); thisView.callButtonReleased() }
    18. onCanceled: console.log("pttButtonMouseArea - onCanceled")
    19. }
    20.  
    21. states: [
    22. State {
    23. name: "stateCallActive"
    24.  
    25. when: callManager.haveCurrentCall && !pttButtonMouseArea.presse
    26. PropertyChanges { target: pttButton; opacity: 1.0 }
    27. PropertyChanges { target: pttButton; enabled: true }
    28. },
    29. State {
    30. name: "stateCallActivePressed"
    31. when: callManager.haveCurrentCall && pttButtonMouseArea.pressed
    32. PropertyChanges { target: pttButton; opacity: 0.7 }
    33. PropertyChanges { target: pttButton; enabled: true }
    34. }
    35. ]
    36. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: MouseArea does not emit onPressed after being cancelled?

    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
    MouseAreaTest.zip

Similar Threads

  1. Replies: 5
    Last Post: 15th August 2011, 21:34
  2. Replies: 2
    Last Post: 16th July 2011, 12:39
  3. Problem with MouseArea element
    By chiru in forum Qt Quick
    Replies: 1
    Last Post: 27th November 2010, 00:23
  4. Replies: 5
    Last Post: 24th July 2009, 22:30

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.