Allow changes to trigger event in ValueWidget after construction (messy still, but possible)

This commit is contained in:
Tony Garnock-Jones 2024-04-17 13:25:06 +02:00
parent 9d8e7f5ccd
commit c1cdf3660f
1 changed files with 9 additions and 8 deletions

View File

@ -196,20 +196,21 @@ export class ValueWidget extends Widget {
this._valueAsNumber = valueAsNumber;
if ('value' in this.node) {
const readValues = (n: any) => {
this.suppressCycleWarning();
this._value.value = n?.value ?? '';
this._valueAsNumber.value = n?.valueAsNumber ?? NaN;
};
this.on(triggerEvent, e => readValues(e.target));
readValues(this.node);
this.on(triggerEvent, () => this.readValues());
this.readValues();
dataflow { this.valueAsNumber = this._valueAsNumber.value; }
dataflow { this.value = this._value.value; }
}
}
readValues() {
const n = this.node as any;
this.suppressCycleWarning();
this._value.value = n.value ?? '';
this._valueAsNumber.value = n.valueAsNumber ?? NaN;
}
get value(): string {
return this._value.value;
}