MCPcopy Create free account
hub / github.com/Shitanshukumar607/Drawspace / handlePointerDown

Function handlePointerDown

hooks/DrawRectangleTool.ts:33–60  ·  view source on GitHub ↗
(e: KonvaEventObject<MouseEvent | TouchEvent>)

Source from the content-addressed store, hash-verified

31 } | null>(null);
32
33 const handlePointerDown = (e: KonvaEventObject<MouseEvent | TouchEvent>) => {
34 if (tool !== "rectangle") return;
35
36 // Save current state before starting new drawing
37 saveToHistory();
38
39 isDrawing.current = true;
40
41 const stage = e.target.getStage();
42 const pos = stage ? getPointerPositionRelativeToStage(stage) : null;
43 if (!pos) return;
44
45 const id = createShapeId();
46 currentDraw.current = { id, startX: pos.x, startY: pos.y };
47
48 addRectangle({
49 id,
50 x: pos.x,
51 y: pos.y,
52 width: 0,
53 height: 0,
54 stroke: properties.stroke,
55 fill: properties.fill,
56 strokeWidth: properties.strokeWidth,
57 cornerRadius: properties.cornerRadius,
58 opacity: properties.opacity,
59 });
60 };
61
62 const handlePointerMove = (e: KonvaEventObject<MouseEvent | TouchEvent>) => {
63 if (!isDrawing.current || tool !== "rectangle") return;

Callers

nothing calls this directly

Calls 2

createShapeIdFunction · 0.90

Tested by

no test coverage detected