chore: add event for updating widget
This commit is contained in:
parent
bf00580562
commit
413115571b
@ -647,7 +647,7 @@ const ext = {
|
|||||||
sendEventToCD("assets", {
|
sendEventToCD("assets", {
|
||||||
node: node.id,
|
node: node.id,
|
||||||
inputName: inputName,
|
inputName: inputName,
|
||||||
})
|
});
|
||||||
// console.log("load image");
|
// console.log("load image");
|
||||||
},
|
},
|
||||||
{ serialize: false },
|
{ serialize: false },
|
||||||
@ -747,6 +747,24 @@ const ext = {
|
|||||||
sendEventToCD("cd_plugin_onGetPrompt", prompt);
|
sendEventToCD("cd_plugin_onGetPrompt", prompt);
|
||||||
} else if (message.type === "event") {
|
} else if (message.type === "event") {
|
||||||
dispatchAPIEventData(message.data);
|
dispatchAPIEventData(message.data);
|
||||||
|
} else if (message.type === "update_widget") {
|
||||||
|
// New handler for updating widget values
|
||||||
|
const { nodeId, widgetName, value } = message.data;
|
||||||
|
const node = app.graph.getNodeById(nodeId);
|
||||||
|
|
||||||
|
if (!node) {
|
||||||
|
console.warn(`Node with ID ${nodeId} not found`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const widget = node.widgets?.find((w) => w.name === widgetName);
|
||||||
|
if (!widget) {
|
||||||
|
console.warn(`Widget ${widgetName} not found in node ${nodeId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
widget.value = value;
|
||||||
|
app.graph.setDirtyCanvas(true);
|
||||||
} else if (message.type === "add_node") {
|
} else if (message.type === "add_node") {
|
||||||
console.log("add node", message.data);
|
console.log("add node", message.data);
|
||||||
app.graph.beforeChange();
|
app.graph.beforeChange();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user