feat: editable labels for INPUT/OUTPUT/CLOCK gates
Double-click any INPUT, OUTPUT, or CLOCK gate to assign a custom label. Labels are shown inside the gate and used in waveform viewer instead of generic IN_0/OUT_0 names. Example circuits now ship with meaningful labels (S, R, D, EN, Q, Q̅, CLK). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
14
js/events.js
14
js/events.js
@@ -147,6 +147,20 @@ export function initEvents() {
|
||||
dragStartPos = null;
|
||||
});
|
||||
|
||||
// Double-click to rename INPUT/OUTPUT/CLOCK gates
|
||||
canvas.addEventListener('dblclick', e => {
|
||||
const world = screenToWorld(e.offsetX, e.offsetY);
|
||||
const gate = findGateAt(world.x, world.y);
|
||||
if (gate && (gate.type === 'INPUT' || gate.type === 'OUTPUT' || gate.type === 'CLOCK')) {
|
||||
const current = gate.label || '';
|
||||
const label = prompt(`Label for ${gate.type}#${gate.id}:`, current);
|
||||
if (label !== null) {
|
||||
gate.label = label.trim() || undefined;
|
||||
console.log(`[label] ${gate.type}#${gate.id} → "${gate.label || ''}"`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
canvas.addEventListener('contextmenu', e => {
|
||||
e.preventDefault();
|
||||
const world = screenToWorld(e.offsetX, e.offsetY);
|
||||
|
||||
Reference in New Issue
Block a user