[solved] how do callback works?

Hello,

I'd like to store the state of widgets somewhere and recall it sometime

Couldn't find by whom mecanism it could be possible, except saving the state into a file

maybe :thinking:

Thanks for the light.

I see the idea, but I wouldn't like to create a variable for each parameter, imagine we have hundreds of parameters... That's why I'm using an object in value that is updated by a script triggered by a button. It would be nice if there would be a way to trigger a single script for all the buttons since it's exactly the same script.

Anyways, I couldn't find how to set a value without triggering the "onValue" script, that causes feedback loops, and wrong value assignements.

A solution would be about using VAR{} somewhere, but I couldn't figure it out.

I might dig again with a custom module using variable widget for storing the states.

set('id', value, {script: false})

would prevent the loop.

1 Like

Thank you, I still not read documentation carefully enough.

AFAIU a callback would be a variable widget where value can contain arguments for the function residing into "onValue" property.

Hi,

is it what you want to achieve ?

1 Like

AFAIU a callback would be a variable widget where value can contain arguments for the function residing into "onValue" property.

I don't understand, callbacks are a pure javascript thing (usually, a function to be called when a specific event occurs), in open stage control there are but a few things referred to as callbacks (ctrl+f "callback" in Scripting - Open Stage Control should cover most of them).

1 Like

Hello,
this solution is quite simple and elegant, thank you for pointing this.

Yes, I'm already using things like setTimeout() but I didn't try runAs() yet.

That is what I'm trying to achieve, calling a single function when some event occurs from different widgets.

The answers I got from this thread should lead me to something neat.

In fact I'm building a 'custom widget' using svg and buttons for svg bindings (maybe there is something more elegant than using button widgets for mouse bindings?).
When I'm done, I should come in the forum with an example's proposal.

1 Like

The canvas widget is an all-in-one solution for custom widgets.