jagenjo / litegraph.js

A graph node engine and editor written in Javascript similar to PD or UDK Blueprints, comes with its own editor in HTML5 Canvas2D. The engine can run client side or server side using Node. It allows to export graphs as JSONs to be included in applications independently.
MIT License
5.32k stars 602 forks source link

Update/Modify widget options #432

Closed Levaru closed 5 months ago

Levaru commented 5 months ago

I have a node with the standard number widget. According to the documentation, it is possible to provide options to that number widget (min, max, step, precision).

Is there a way to modify those options after the widget was created? I tried setting it directly via this.widget.options = my_options but this had no effect.

Levaru commented 5 months ago

I found a workaround after looking at the source code:

this.widgets[0].options = my_options

Right now this is enough for me but it would be great if there was an additional function like setProperty. Maybe something like setWidgetOptions(widget_index, options) or setWidgetOptions(widget_index, option_name, value)?

jagenjo commented 5 months ago

it is just a regular JS object holding all the options, accessing it directly makes more sense.