Hi,
i have a custom type, QDeclarativeItem subclass called polygon.
I override shape, boundingRect and paint functions in it.
I can see the polygons that i describe in the below QML code:
Code:import MyTypes 1.0 import QtQuick 1.0 import Qt 4.7 Item { id: container width: 350; height: 250 Polygon { id: aPolygon x:0;y:0 width: 20; height: 20 name: "A simple polygon" color: "blue" vertices:[ Point{x:20.0; y:40.0}, Point{x:40.0; y:40.0}, Point{x:40.0; y:20.0}, Point{x:20.0; y:20.0} ] MouseArea{ anchors.fill: parent drag.target: aPolygon drag.axis: Drag.XandYAxis drag.minimumX: 0 drag.maximumX: container.width - parent.width drag.minimumY: 0 drag.maximumY: container.height - parent.width onPressed:console.log("============== ==onPressed") } } Polygon { id: bPolygon x:60;y:60 width: 20; height: 20 name: "A simple polygon" color: "blue" vertices:[ Point{x:60.0; y:80.0}, Point{x:80.0; y:80.0}, Point{x:80.0; y:60.0}, Point{x:60.0; y:60.0} ] MouseArea{ //hoverEnabled: false enabled: visible hoverEnabled: visible anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton onEntered: { console.log("============== ==onEntered") } } } }
The problem is that MouseArea cares the x, y, width and height properties of my polygon items, not the shape of my polygons.
For example for first polygon onPressed work for the rectangle x:0;y:0;width:20;height:20
How can i make MouseArea work for the polygon that vertices define.
I have overrided shape function, what should i do else?
Thanks



