Add event when readonly changes (#160)

* Add even when readonly is changed

* Swap to ts private instead of es
This commit is contained in:
pythongosssss
2024-09-27 14:41:10 +09:00
committed by GitHub
parent 70ca8b7c21
commit 1c6f04f1db
2 changed files with 16 additions and 1 deletions

View File

@@ -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;

View File

@@ -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;