diff --git a/tracker/tracker/src/main/app/ticker.ts b/tracker/tracker/src/main/app/ticker.ts index 70bffdf4c..ee05ed93c 100644 --- a/tracker/tracker/src/main/app/ticker.ts +++ b/tracker/tracker/src/main/app/ticker.ts @@ -18,6 +18,12 @@ export default class Ticker { this.callbacks = [] } + /** + * @param {Callback} callback - repeated cb + * @param {number} n - number of turn skips; ticker have a 30 ms cycle + * @param {boolean} useSafe - using safe wrapper to check if app is active + * @param {object} thisArg - link to + * */ attach(callback: Callback, n = 0, useSafe = true, thisArg?: any) { if (thisArg) { callback = callback.bind(thisArg) diff --git a/tracker/tracker/src/main/modules/input.ts b/tracker/tracker/src/main/modules/input.ts index f6b915e25..9e929e782 100644 --- a/tracker/tracker/src/main/modules/input.ts +++ b/tracker/tracker/src/main/modules/input.ts @@ -153,6 +153,25 @@ export default function (app: App, opts: Partial): void { sendInputValue(id, node) }, 60) + app.ticker.attach(() => { + inputValues.forEach((value, id) => { + const node = app.nodes.getNode(id) as HTMLInputElement + if (!node) return inputValues.delete(id) + if (value !== node.value) { + inputValues.set(id, node.value) + sendInputValue(id, node) + } + }) + checkboxValues.forEach((checked, id) => { + const node = app.nodes.getNode(id) as HTMLInputElement + if (!node) return checkboxValues.delete(id) + if (checked !== node.checked) { + checkboxValues.set(id, node.checked) + app.send(SetInputChecked(id, node.checked)) + } + }) + }, 5) + app.nodes.attachNodeCallback( app.safe((node: Node): void => { const id = app.nodes.getID(node)