Skip to content

Commit 9d095c5

Browse files
committed
handle double click create primitive widget
1 parent 2dc7257 commit 9d095c5

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

web/extensions/core/widgetInputs.js

Lines changed: 21 additions & 18 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
},
@@ -265,7 +269,6 @@ app.registerExtension({
265269

266270
const widget = _widget;
267271
const { type, linkType } = getWidgetType(widget.config);
268-
console.log({ "input": input });
269272
// Update our output to restrict to the widget type
270273
this.outputs[0].type = linkType;
271274
this.outputs[0].name = type;

0 commit comments

Comments
 (0)