mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Add right click to delete points in desktop mask/zone editor (#12744)
This commit is contained in:
parent
096e2791f5
commit
07b3160dff
@ -114,6 +114,29 @@ export function PolygonCanvas({
|
|||||||
const mousePos = stage.getPointerPosition() ?? { x: 0, y: 0 };
|
const mousePos = stage.getPointerPosition() ?? { x: 0, y: 0 };
|
||||||
const intersection = stage.getIntersection(mousePos);
|
const intersection = stage.getIntersection(mousePos);
|
||||||
|
|
||||||
|
// right click on desktops to delete a point
|
||||||
|
if (
|
||||||
|
e.evt instanceof MouseEvent &&
|
||||||
|
e.evt.button === 2 &&
|
||||||
|
intersection?.getClassName() == "Circle"
|
||||||
|
) {
|
||||||
|
const pointIndex = parseInt(intersection.name()?.split("-")[1]);
|
||||||
|
if (!isNaN(pointIndex)) {
|
||||||
|
const updatedPoints = activePolygon.points.filter(
|
||||||
|
(_, index) => index !== pointIndex,
|
||||||
|
);
|
||||||
|
updatedPolygons[activePolygonIndex] = {
|
||||||
|
...activePolygon,
|
||||||
|
points: updatedPoints,
|
||||||
|
pointsOrder: activePolygon.pointsOrder?.filter(
|
||||||
|
(_, index) => index !== pointIndex,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
setPolygons(updatedPolygons);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
activePolygon.points.length >= 3 &&
|
activePolygon.points.length >= 3 &&
|
||||||
intersection?.getClassName() == "Circle" &&
|
intersection?.getClassName() == "Circle" &&
|
||||||
@ -236,6 +259,9 @@ export function PolygonCanvas({
|
|||||||
onMouseDown={handleMouseDown}
|
onMouseDown={handleMouseDown}
|
||||||
onTouchStart={handleMouseDown}
|
onTouchStart={handleMouseDown}
|
||||||
onMouseOver={handleStageMouseOver}
|
onMouseOver={handleStageMouseOver}
|
||||||
|
onContextMenu={(e) => {
|
||||||
|
e.evt.preventDefault();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Layer>
|
<Layer>
|
||||||
<Image
|
<Image
|
||||||
|
@ -80,7 +80,7 @@ export default function PolygonEditControls({
|
|||||||
<MdUndo className="text-secondary-foreground" />
|
<MdUndo className="text-secondary-foreground" />
|
||||||
</Button>
|
</Button>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>Undo</TooltipContent>
|
<TooltipContent>Remove last point</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
|
Loading…
Reference in New Issue
Block a user