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

Function handlePointerDown

hooks/DrawLineTool.ts:25–50  ·  view source on GitHub ↗
(e: KonvaEventObject<MouseEvent | TouchEvent>)

Source from the content-addressed store, hash-verified

23 const currentLineId = useRef<string | null>(null);
24
25 const handlePointerDown = (e: KonvaEventObject<MouseEvent | TouchEvent>) => {
26 if (tool !== "line") return;
27
28 // Save current state before starting new drawing
29 saveToHistory();
30
31 isDrawing.current = true;
32
33 const stage = e.target.getStage();
34 const pos = stage ? getPointerPositionRelativeToStage(stage) : null;
35 if (!pos) return;
36
37 const newLine: LineShapeWithProps = {
38 id: createShapeId(),
39 initialX: pos.x,
40 initialY: pos.y,
41 x: pos.x,
42 y: pos.y,
43 stroke: properties.stroke,
44 strokeWidth: properties.strokeWidth,
45 opacity: properties.opacity,
46 };
47
48 addLine(newLine);
49 currentLineId.current = newLine.id;
50 };
51
52 const handlePointerMove = (e: KonvaEventObject<MouseEvent | TouchEvent>) => {
53 if (!isDrawing.current || tool !== "line") return;

Callers

nothing calls this directly

Calls 2

createShapeIdFunction · 0.90

Tested by

no test coverage detected