Skip to content

Commit

Permalink
✨ node propertyChanged event
Browse files Browse the repository at this point in the history
  • Loading branch information
zhzLuke96 committed May 26, 2024
1 parent b3143d9 commit 903cb2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@litegraph-ts/core",
"version": "0.2.18",
"version": "0.2.19",
"description": "A graph node editor similar to PD or UDK Blueprints. It works in an HTML5 Canvas and allows to export graphs to be included in applications.",
"source": "src/index.ts",
"types": "src/index.ts",
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/LGraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export default class LGraphNode {
nodeOptionalInputAdd: (slot: INodeInputSlot) => void;
nodeOptionalOutputAdd: (slot: INodeOutputSlot) => void;
resize: (size: Vector2) => void;
propertyChanged: (k: string, v: any, prev_v: any) => void;
}>();

// sync position with the node
Expand Down Expand Up @@ -369,6 +370,12 @@ export default class LGraphNode {
if (this.onPropertyChanged) {
this.onPropertyChanged(k, info.properties[k]);
}
this.events.emit(
"propertyChanged",
k,
info.properties[k],
undefined,
);
}
continue;
}
Expand Down Expand Up @@ -625,6 +632,7 @@ export default class LGraphNode {
//abort change
this.properties[name] = prev_value;
}
this.events.emit("propertyChanged", name, value, prev_value);
if (this.widgets)
//widgets could be linked to properties
for (var i = 0; i < this.widgets.length; ++i) {
Expand Down

0 comments on commit 903cb2c

Please sign in to comment.