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
0bb5f93b
Commit
0bb5f93b
authored
Apr 06, 2023
by
comfyanonymous
Browse files
Merge branch 'image-node-keybindings' of
https://github.com/ALSchwalm/ComfyUI
parents
fb73d008
bf7dbe47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
web/scripts/app.js
web/scripts/app.js
+41
-0
No files found.
web/scripts/app.js
View file @
0bb5f93b
...
...
@@ -112,6 +112,46 @@ class ComfyApp {
};
}
#
addNodeKeyHandler
(
node
)
{
const
app
=
this
;
const
origNodeOnKeyDown
=
node
.
prototype
.
onKeyDown
;
node
.
prototype
.
onKeyDown
=
function
(
e
)
{
if
(
origNodeOnKeyDown
&&
origNodeOnKeyDown
.
apply
(
this
,
e
)
===
false
)
{
return
false
;
}
if
(
this
.
flags
.
collapsed
||
!
this
.
imgs
||
this
.
imageIndex
===
null
)
{
return
;
}
let
handled
=
false
;
if
(
e
.
key
===
"
ArrowLeft
"
||
e
.
key
===
"
ArrowRight
"
)
{
if
(
e
.
key
===
"
ArrowLeft
"
)
{
this
.
imageIndex
-=
1
;
}
else
if
(
e
.
key
===
"
ArrowRight
"
)
{
this
.
imageIndex
+=
1
;
}
this
.
imageIndex
%=
this
.
imgs
.
length
;
if
(
this
.
imageIndex
<
0
)
{
this
.
imageIndex
=
this
.
imgs
.
length
+
this
.
imageIndex
;
}
handled
=
true
;
}
else
if
(
e
.
key
===
"
Escape
"
)
{
this
.
imageIndex
=
null
;
handled
=
true
;
}
if
(
handled
===
true
)
{
e
.
preventDefault
();
e
.
stopImmediatePropagation
();
return
false
;
}
}
}
/**
* Adds Custom drawing logic for nodes
* e.g. Draws images and handles thumbnail navigation on nodes that output images
...
...
@@ -803,6 +843,7 @@ class ComfyApp {
this
.
#
addNodeContextMenuHandler
(
node
);
this
.
#
addDrawBackgroundHandler
(
node
,
app
);
this
.
#
addNodeKeyHandler
(
node
);
await
this
.
#
invokeExtensionsAsync
(
"
beforeRegisterNodeDef
"
,
node
,
nodeData
);
LiteGraph
.
registerNodeType
(
nodeId
,
node
);
...
...
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