diff --git a/public/litegraph.d.ts b/public/litegraph.d.ts index 16ef84b62..3f63bec72 100644 --- a/public/litegraph.d.ts +++ b/public/litegraph.d.ts @@ -1393,6 +1393,7 @@ export declare class LGraphCanvas { graph_mouse: Vector2; pointer_is_down?: boolean; + read_only: boolean; /** clears all the data inside */ clear(): void; diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index 43ae3c648..aeaa7ebdf 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -69,6 +69,21 @@ export class LGraphCanvas { } } + // if set to true users cannot modify the graph + private _read_only = false; + get read_only() { + return this._read_only + } + set read_only(value) { + if (value != this._read_only) { + this._read_only = value; + this.emitEvent({ + subType: "read-only", + readOnly: value + }) + } + } + constructor(canvas, graph, options) { this.options = options = options || {}; @@ -113,7 +128,6 @@ export class LGraphCanvas { this.clear_background = true; this.clear_background_color = "#222"; - this.read_only = false; //if set to true users cannot modify the graph this.render_only_selected = true; this.live_mode = false; this.show_info = true;