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
d6830b95
Commit
d6830b95
authored
Mar 24, 2023
by
pythongosssss
Browse files
Prevent exactly overlapping nodes
Throttle double click
parent
1fa9ccaa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
web/extensions/core/widgetInputs.js
web/extensions/core/widgetInputs.js
+27
-3
No files found.
web/extensions/core/widgetInputs.js
View file @
d6830b95
...
...
@@ -139,17 +139,41 @@ app.registerExtension({
return
r
;
};
function
isNodeAtPos
(
pos
)
{
for
(
const
n
of
app
.
graph
.
_nodes
)
{
if
(
n
.
pos
[
0
]
===
pos
[
0
]
&&
n
.
pos
[
1
]
===
pos
[
1
])
{
return
true
;
}
}
return
false
;
}
// Double click a widget input to automatically attach a primitive
const
origOnInputDblClick
=
nodeType
.
prototype
.
onInputDblClick
;
const
ignoreDblClick
=
Symbol
();
nodeType
.
prototype
.
onInputDblClick
=
function
(
slot
)
{
const
r
=
origOnInputDblClick
?
origOnInputDblClick
.
apply
(
this
,
arguments
)
:
undefined
;
if
(
this
.
inputs
[
slot
].
widget
)
{
const
input
=
this
.
inputs
[
slot
];
if
(
input
.
widget
&&
!
input
[
ignoreDblClick
])
{
const
node
=
LiteGraph
.
createNode
(
"
PrimitiveNode
"
);
app
.
graph
.
add
(
node
);
node
.
pos
=
[
this
.
pos
[
0
]
-
node
.
size
[
0
]
-
30
,
this
.
pos
[
1
]];
// 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
;
node
.
connect
(
0
,
this
,
slot
);
node
.
title
=
this
.
inputs
[
slot
].
name
;
node
.
title
=
input
.
name
;
// Prevent adding duplicates due to triple clicking
input
[
ignoreDblClick
]
=
true
;
setTimeout
(()
=>
{
delete
input
[
ignoreDblClick
];
},
300
);
}
return
r
;
...
...
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