Type a repeat delay as whole milliseconds

The two On key down fields read in milliseconds now, and say so in their
labels. A number field shows three decimals unless a property asks for
fewer, so both params set decimals: 0 – the field reads 300, not 300.000,
and rounds to whole milliseconds while typing or scrubbing. The clock
behind it still counts seconds; the conversion sits at the one place that
reads the properties.
This commit is contained in:
root committed 2026-09-10 05:59:39 +02:00
1 parent 3ab8d88ad6
commit 338ff4389f
3 files changed
+44 -10

No files matched your search

+20 -2
View File
@@ -11,8 +11,26 @@ export const OnKeyDown: NodeDef = {
outputs: [exec()],
params: [
keyParam,
{ key: 'repeatAfter', label: 'Repeat after (ms)', kind: 'number', default: 0, min: 0, step: 50 },
{ key: 'repeatInterval', label: 'Repeat interval (ms)', kind: 'number', default: 0, min: 0, step: 10 },
// `decimals: 0`: a millisecond is the finest step the repeat clock reads, so a fractional
// field would only ever show a ".000" nothing can use.
{
key: 'repeatAfter',
label: 'Repeat after (ms)',
kind: 'number',
default: 0,
min: 0,
step: 50,
decimals: 0,
},
{
key: 'repeatInterval',
label: 'Repeat interval (ms)',
kind: 'number',
default: 0,
min: 0,
step: 10,
decimals: 0,
},
],
// Both rows go together: with no delay there is no repeat, so the interval is not in play either.
hiddenParams: (params) => (asNumber(params.repeatAfter ?? 0) > 0 ? [] : ['repeatAfter', 'repeatInterval']),
+15
View File
@@ -6,6 +6,7 @@ import { describe, expect, it } from 'vitest';
import { nodeDef } from '../../src/core/graph';
import { MIN_REPEAT_INTERVAL, stepKeyRepeat } from '../../src/core/graph/keyRepeat';
import type { PropertyBag } from '../../src/core/model/Properties';
import { formatNumber } from '../../src/ui/math';
const held = { pressed: false, down: true, dt: 0.1, after: 0.2, interval: 0.2 };
@@ -71,3 +72,17 @@ describe('the repeat rows on the node body', () => {
expect(hidden({ key: 'a', repeatAfter: 300, repeatInterval: 0 })).toEqual([]);
});
});
describe('the repeat fields in the inspector', () => {
const param = (key: string) => {
const def = nodeDef('OnKeyDown')?.params.find((p) => p.key === key);
return def?.kind === 'number' ? def : null;
};
it('types both as whole milliseconds, so the field shows 300 and not 300.000', () => {
for (const key of ['repeatAfter', 'repeatInterval']) {
expect(param(key)?.decimals).toBe(0);
expect(formatNumber(300, param(key)?.decimals)).toBe('300');
}
});
});
+9 -8
View File
@@ -28,6 +28,10 @@ Beide Felder sind **Millisekunden** — damit bleiben die ueblichen Werte ganze
statt 0,3 und 0,05. Die Uhr dahinter rechnet weiter in Sekunden; umgerechnet wird beim Auslesen
der Node-Properties.
Beide tragen `decimals: 0`: das Inspector-Zahlenfeld zeigt sonst immer drei Nachkommastellen
(`NUMBER_DECIMALS`), also stand dort `300.000`. Der Node-Koerper war davon nie betroffen —
`formatValue` gibt ganze Zahlen bar aus.
Der erste Druck feuert immer sofort und unveraendert — die Wiederholung haengt nur hinten dran.
### Warum das nicht der Auto-Repeat des Browsers ist
@@ -63,19 +67,16 @@ Zwei `On key down` auf **derselben** Taste, einer schlicht, einer wiederholend
Halten misst beide, damit "es hat wiederholt" nicht mit "die Taste kam oefter an" verwechselt
werden kann.
Die folgende Ausgabe stammt aus dem Lauf **vor** der Umstellung auf Millisekunden (daher `0.300` /
`0.050` / `0.75 s`); das Modul tippt jetzt `300`, `50` und `750`. Der Nachlauf steht aus.
```
PASS a hold shorter than the delay fires once, repeat or not
– plain 0 → 1, repeating 0 → 1 over 120 ms with a 0.3 s delay
– plain 0 → 1, repeating 0 → 1 over 120 ms with a 300 ms delay
PASS holding past the delay keeps the repeating node firing, while the plain one counts one press
– plain +1, repeating +11 over 800 ms (press + ~10 repeats expected)
– plain +1, repeating +12 over 800 ms (press + ~10 repeats expected)
PASS a node with no repeat set carries no repeat rows, the repeating one carries both
– plain ["Key: Right arrow"], repeating [… "Repeat after (s): 0.300", "Repeat interval (s): 0.050"]
PASS typing a new delay lands on the node
– plain ["Key: Right arrow"], repeating [… "Repeat after (ms): 300", "Repeat interval (ms): 50"]
PASS typing a new delay lands on the node – {"key":"ArrowRight","repeatAfter":750,"repeatInterval":50}
PASS the delay typed into the inspector is the one the run uses
– repeating 0 → 1 over 500 ms with the delay raised to 0.75 s
– repeating 0 → 1 over 500 ms with the delay raised to 750 ms
```
Der letzte ist der wichtigste: derselbe Graph, nur die getippte Zahl geaendert — und der Node