Fix widget creation for Primitive Node

widget creation in #createWidget is now aware of widget subtype like "INT:seed"
meaning, it does not need special treatment for the randomizeWidget anymore
This commit is contained in:
flyingshutter 2023-03-30 23:52:43 +02:00
parent 9a27030519
commit 5794ff7933

View File

@ -271,10 +271,20 @@ app.registerExtension({
}
let widget;
if (type in ComfyWidgets) {
widget = (ComfyWidgets[type](this, "value", inputData, app) || {}).widget;
// ComfyWidgets allows a subtype of widgets which is defined by "<type>:<widgetName>"
// common example is "INT:seed"
// so let's check for those first
let combinedWidgetType = type + ":" + widgetName;
if (combinedWidgetType in ComfyWidgets) {
widget = (ComfyWidgets[combinedWidgetType](this, "value", inputData, app) || {}).widget;
} else {
widget = this.addWidget(type, "value", null, () => {}, {});
// we did not find a subtype, so proceed with "<type>" only
if (type in ComfyWidgets) {
widget = (ComfyWidgets[type](this, "value", inputData, app) || {}).widget;
} else {
widget = this.addWidget(type, "value", null, () => {}, {});
}
}
if (node?.widgets && widget) {
@ -284,10 +294,6 @@ app.registerExtension({
}
}
if (widget.type === "number") {
addRandomizeWidget(this, widget, "Random after every gen");
}
// When our value changes, update other widgets to reflect our changes
// e.g. so LoadImage shows correct image
const callback = widget.callback;