diff --git a/src/components/canvas/Canvas.tsx b/src/components/canvas/Canvas.tsx index c81b9a1..d1f9fa6 100644 --- a/src/components/canvas/Canvas.tsx +++ b/src/components/canvas/Canvas.tsx @@ -433,6 +433,21 @@ function Canvas() { setBlocks((prev) => prev.filter((b) => !selectionCoords.some(([x2, y2]) => x2 === b.x && y2 === b.y))); break; } + case "a": { + if (!e.ctrlKey) return; + e.preventDefault(); + + const newSelection: CoordinateArray = []; + + for (let x = canvasSize.minX; x < canvasSize.maxX; x++) { + for (let y = canvasSize.minY; y < canvasSize.maxY; y++) { + newSelection.push([x, y]); + } + } + + setSelectionCoords(newSelection); + break; + } case "c": { if (!e.ctrlKey) return; clipboard.copy(selectionCoords, blocks); @@ -487,7 +502,19 @@ function Canvas() { } } }, - [tool, blocks, selectionCoords, selectionLayerBlocks, blockData, setBlocks, setCssCursor, setSelectionLayerBlocks, setTool] + [ + tool, + blocks, + selectionCoords, + selectionLayerBlocks, + canvasSize, + blockData, + setBlocks, + setCssCursor, + setSelectionCoords, + setSelectionLayerBlocks, + setTool, + ] ); const onKeyUp = useCallback( diff --git a/src/components/menubar/SelectMenu.tsx b/src/components/menubar/SelectMenu.tsx index aeacbb8..3426917 100644 --- a/src/components/menubar/SelectMenu.tsx +++ b/src/components/menubar/SelectMenu.tsx @@ -11,10 +11,27 @@ function SelectMenu() { const { canvasSize } = useContext(CanvasContext); const { coords: selectionCoords, setCoords: setSelectionCoords } = useContext(SelectionContext); + // Add every block within the canvas size to the temporary array + const selectAll = () => { + const newSelection: CoordinateArray = []; + + for (let x = canvasSize.minX; x < canvasSize.maxX; x++) { + for (let y = canvasSize.minY; y < canvasSize.maxY; y++) { + newSelection.push([x, y]); + } + } + + setSelectionCoords(newSelection); + }; + return ( Select + + All + Ctrl A + setSelectionCoords([])}>Clear