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:
1 parent
3ab8d88ad6
commit
338ff4389f
3 files changed
+44
-10
No files matched your search
@@ -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');
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user