Hello,

I have a custom QDeclarativeItem subclass named Polygon. I add a MouseArea in it but onEntered or onPressed does not working, or am i expect wrong thing to happen? I can see my polygons on the window but nothing is writing on console onPressed or onEntered.

Here is QML file:
Qt Code:
  1. import MyTypes 1.0
  2. import QtQuick 1.0
  3. import Qt 4.7
  4.  
  5. Item {
  6. id: container
  7. width: 350; height: 250
  8.  
  9. Polygon {
  10. id: aPolygon
  11.  
  12. width: 20; height: 20
  13. name: "A simple polygon"
  14. color: "blue"
  15. vertices:[
  16.  
  17. Point{x:20.0; y:40.0},
  18. Point{x:40.0; y:40.0},
  19. Point{x:40.0; y:20.0},
  20. Point{x:20.0; y:20.0}
  21. ]
  22.  
  23. MouseArea{
  24. anchors.fill: parent
  25. drag.target: aPolygon
  26. drag.axis: Drag.XandYAxis
  27. drag.minimumX: 0
  28. drag.maximumX: container.width - parent.width
  29. drag.minimumY: 0
  30. drag.maximumY: container.height - parent.width
  31. onPressed:console.log("============== ==onPressed")
  32.  
  33. }
  34.  
  35.  
  36. }
  37.  
  38. Polygon {
  39. id: bPolygon
  40. //anchors.centerIn: parent
  41. width: 20; height: 20
  42. name: "A simple polygon"
  43. color: "blue"
  44. vertices:[
  45.  
  46. Point{x:60.0; y:80.0},
  47. Point{x:80.0; y:80.0},
  48. Point{x:80.0; y:60.0},
  49. Point{x:60.0; y:60.0}
  50. ]
  51.  
  52. MouseArea{
  53. //hoverEnabled: false
  54. enabled: visible
  55. hoverEnabled: visible
  56. anchors.fill: parent
  57. acceptedButtons: Qt.LeftButton | Qt.RightButton
  58. onEntered: {
  59. console.log("============== ==onEntered")
  60.  
  61. }
  62. }
  63.  
  64.  
  65. }
  66. }
To copy to clipboard, switch view to plain text mode 

Thanks for any idea.