Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
9d095c52
Commit
9d095c52
authored
Apr 08, 2023
by
omar92
Browse files
handle double click create primitive widget
parent
2dc7257e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
18 deletions
+21
-18
web/extensions/core/widgetInputs.js
web/extensions/core/widgetInputs.js
+21
-18
No files found.
web/extensions/core/widgetInputs.js
View file @
9d095c52
...
@@ -159,27 +159,31 @@ app.registerExtension({
...
@@ -159,27 +159,31 @@ app.registerExtension({
const
r
=
origOnInputDblClick
?
origOnInputDblClick
.
apply
(
this
,
arguments
)
:
undefined
;
const
r
=
origOnInputDblClick
?
origOnInputDblClick
.
apply
(
this
,
arguments
)
:
undefined
;
const
input
=
this
.
inputs
[
slot
];
const
input
=
this
.
inputs
[
slot
];
if
(
input
.
widget
&&
!
input
[
ignoreDblClick
])
{
if
(
!
input
.
widget
||
!
input
[
ignoreDblClick
])
// Not a widget input or already handled input
const
node
=
LiteGraph
.
createNode
(
"
PrimitiveNode
"
);
{
app
.
graph
.
add
(
node
);
if
(
!
(
input
.
type
in
ComfyWidgets
))
return
r
;
//also Not a ComfyWidgets input (do nothing)
}
// Calculate a position that wont directly overlap another node
const
pos
=
[
this
.
pos
[
0
]
-
node
.
size
[
0
]
-
30
,
this
.
pos
[
1
]];
while
(
isNodeAtPos
(
pos
))
{
pos
[
1
]
+=
LiteGraph
.
NODE_TITLE_HEIGHT
;
}
node
.
pos
=
pos
;
// Create a primitive node
node
.
connect
(
0
,
this
,
slot
);
const
node
=
LiteGraph
.
createNode
(
"
PrimitiveNode
"
);
node
.
title
=
input
.
name
;
app
.
graph
.
add
(
node
)
;
// Prevent adding duplicates due to triple clicking
// Calculate a position that wont directly overlap another node
input
[
ignoreDblClick
]
=
true
;
const
pos
=
[
this
.
pos
[
0
]
-
node
.
size
[
0
]
-
30
,
this
.
pos
[
1
]];
setTimeout
(()
=>
{
while
(
isNodeAtPos
(
pos
))
{
delete
input
[
ignoreDblClick
];
pos
[
1
]
+=
LiteGraph
.
NODE_TITLE_HEIGHT
;
},
300
);
}
}
node
.
pos
=
pos
;
node
.
connect
(
0
,
this
,
slot
);
node
.
title
=
input
.
name
;
// Prevent adding duplicates due to triple clicking
input
[
ignoreDblClick
]
=
true
;
setTimeout
(()
=>
{
delete
input
[
ignoreDblClick
];
},
300
);
return
r
;
return
r
;
};
};
},
},
...
@@ -265,7 +269,6 @@ app.registerExtension({
...
@@ -265,7 +269,6 @@ app.registerExtension({
const
widget
=
_widget
;
const
widget
=
_widget
;
const
{
type
,
linkType
}
=
getWidgetType
(
widget
.
config
);
const
{
type
,
linkType
}
=
getWidgetType
(
widget
.
config
);
console
.
log
({
"
input
"
:
input
});
// Update our output to restrict to the widget type
// Update our output to restrict to the widget type
this
.
outputs
[
0
].
type
=
linkType
;
this
.
outputs
[
0
].
type
=
linkType
;
this
.
outputs
[
0
].
name
=
type
;
this
.
outputs
[
0
].
name
=
type
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment