[ui] Edge: Added mouse area which checks clicks on edgeArea

The workaround on edge crashing is to use the mouse area around the edge and query if the click exists in the edge to accept pressed or released signal
This commit is contained in:
waaake 2025-02-03 17:02:57 +05:30
parent 5bcc55c19f
commit efb13f1d7d

View file

@ -139,12 +139,35 @@ Item {
acceptedButtons: Qt.LeftButton | Qt.RightButton
thickness: root.thickness + 4
curveScale: cubic.ctrlPtDist / root.width // Normalize by width
}
MouseArea {
x: Math.min(0, root.width)
y: Math.min(0, root.height)
height: Math.abs(root.height)
width: Math.abs(root.width)
acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressed: function(event) {
root.pressed(event)
}
onReleased: function(event) {
root.released(event)
let xpos = root.width < 0 ? root.height + event.x : event.x;
let ypos = root.height < 0 ? root.height + event.y: event.y;
if (edgeArea.containsPoint(Qt.point(xpos, ypos))) {
root.pressed(event);
}
else {
event.accepted = false;
}
}
onReleased: function(event) {
let xpos = root.width < 0 ? root.height + event.x : event.x;
let ypos = root.height < 0 ? root.height + event.y: event.y;
if (edgeArea.containsPoint(Qt.point(xpos, ypos))) {
root.released(event);
}
else {
event.accepted = false;
}
}
}
}