feat: keep placing mode active for multiple placements

Selected gate type stays active after placing, allowing multiple
gates of the same type without re-selecting. Right-click or Escape
to cancel placing mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jose Luis
2026-03-20 04:28:10 +01:00
parent 2fd22cc79d
commit 89d118f738

View File

@@ -90,7 +90,7 @@ export function initEvents() {
} }
state.gates.push(newGate); state.gates.push(newGate);
evaluateAll(); evaluateAll();
state.placingGate = null; // Keep placingGate active so user can place multiple — right-click to cancel
return; return;
} }
@@ -172,6 +172,13 @@ export function initEvents() {
canvas.addEventListener('contextmenu', e => { canvas.addEventListener('contextmenu', e => {
e.preventDefault(); e.preventDefault();
// Right-click cancels placing mode
if (state.placingGate) {
state.placingGate = null;
return;
}
const world = screenToWorld(e.offsetX, e.offsetY); const world = screenToWorld(e.offsetX, e.offsetY);
const port = findPortAt(world.x, world.y); const port = findPortAt(world.x, world.y);
if (port && port.type === 'input') { if (port && port.type === 'input') {