Skip to content

Commit 61e7767

Browse files
Merge branch 'Allow-connect-premitiveNode-to-forceInput-comfyiUI-nodes' of https://github.com/omar92/ComfyUI
2 parents d98a4de + 9d095c5 commit 61e7767

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

web/extensions/core/widgetInputs.js

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -159,27 +159,31 @@ app.registerExtension({
159159
const r = origOnInputDblClick ? origOnInputDblClick.apply(this, arguments) : undefined;
160160

161161
const input = this.inputs[slot];
162-
if (input.widget && !input[ignoreDblClick]) {
163-
const node = LiteGraph.createNode("PrimitiveNode");
164-
app.graph.add(node);
165-
166-
// Calculate a position that wont directly overlap another node
167-
const pos = [this.pos[0] - node.size[0] - 30, this.pos[1]];
168-
while (isNodeAtPos(pos)) {
169-
pos[1] += LiteGraph.NODE_TITLE_HEIGHT;
170-
}
162+
if (!input.widget || !input[ignoreDblClick])// Not a widget input or already handled input
163+
{
164+
if (!(input.type in ComfyWidgets)) return r;//also Not a ComfyWidgets input (do nothing)
165+
}
171166

172-
node.pos = pos;
173-
node.connect(0, this, slot);
174-
node.title = input.name;
167+
// Create a primitive node
168+
const node = LiteGraph.createNode("PrimitiveNode");
169+
app.graph.add(node);
175170

176-
// Prevent adding duplicates due to triple clicking
177-
input[ignoreDblClick] = true;
178-
setTimeout(() => {
179-
delete input[ignoreDblClick];
180-
}, 300);
171+
// Calculate a position that wont directly overlap another node
172+
const pos = [this.pos[0] - node.size[0] - 30, this.pos[1]];
173+
while (isNodeAtPos(pos)) {
174+
pos[1] += LiteGraph.NODE_TITLE_HEIGHT;
181175
}
182176

177+
node.pos = pos;
178+
node.connect(0, this, slot);
179+
node.title = input.name;
180+
181+
// Prevent adding duplicates due to triple clicking
182+
input[ignoreDblClick] = true;
183+
setTimeout(() => {
184+
delete input[ignoreDblClick];
185+
}, 300);
186+
183187
return r;
184188
};
185189
},
@@ -233,7 +237,9 @@ app.registerExtension({
233237
// Fires before the link is made allowing us to reject it if it isn't valid
234238

235239
// No widget, we cant connect
236-
if (!input.widget) return false;
240+
if (!input.widget) {
241+
if (!(input.type in ComfyWidgets)) return false;
242+
}
237243

238244
if (this.outputs[slot].links?.length) {
239245
return this.#isValidConnection(input);
@@ -252,9 +258,17 @@ app.registerExtension({
252258
const input = theirNode.inputs[link.target_slot];
253259
if (!input) return;
254260

255-
const widget = input.widget;
256-
const { type, linkType } = getWidgetType(widget.config);
257261

262+
var _widget;
263+
if (!input.widget) {
264+
if (!(input.type in ComfyWidgets)) return;
265+
_widget = { "name": input.name, "config": [input.type, {}] }//fake widget
266+
} else {
267+
_widget = input.widget;
268+
}
269+
270+
const widget = _widget;
271+
const { type, linkType } = getWidgetType(widget.config);
258272
// Update our output to restrict to the widget type
259273
this.outputs[0].type = linkType;
260274
this.outputs[0].name = type;
@@ -274,7 +288,7 @@ app.registerExtension({
274288
if (type in ComfyWidgets) {
275289
widget = (ComfyWidgets[type](this, "value", inputData, app) || {}).widget;
276290
} else {
277-
widget = this.addWidget(type, "value", null, () => {}, {});
291+
widget = this.addWidget(type, "value", null, () => { }, {});
278292
}
279293

280294
if (node?.widgets && widget) {

0 commit comments

Comments
 (0)