1
- // ComfyUI.mxToolkit.Reroute v.0.9c - Max Smirnov 2024
1
+ // ComfyUI.mxToolkit.Reroute v.0.9d - Max Smirnov 2024
2
2
import { app } from "../../scripts/app.js" ;
3
3
import { mergeIfValid , getWidgetConfig , setWidgetConfig } from "../core/widgetInputs.js" ;
4
4
@@ -17,6 +17,7 @@ app.registerExtension({
17
17
this . properties . outputDir = "RIGHT" ;
18
18
this . linkType = "*" ;
19
19
this . bgcolor = "rgba(20,20,200,0.0)" ;
20
+ this . keyCode = 0 ;
20
21
21
22
this . size = [ 2 * LiteGraph . CANVAS_GRID_SIZE + 1.4 * LiteGraph . NODE_SLOT_HEIGHT , 2 * LiteGraph . CANVAS_GRID_SIZE + 1.4 * LiteGraph . NODE_SLOT_HEIGHT ] ;
22
23
@@ -73,7 +74,22 @@ app.registerExtension({
73
74
ctx . fill ( ) ;
74
75
}
75
76
}
76
-
77
+
78
+ this . onKeyUp = function ( e )
79
+ {
80
+ if ( e . keyCode < 37 || e . keyCode > 40 ) return ;
81
+ if ( this . keyCode > 0 )
82
+ {
83
+ const arrowKeys = { 37 : "LEFT" , 38 : "UP" , 39 : "RIGHT" , 40 : "DOWN" } ;
84
+ this . properties . inputDir = arrowKeys [ this . keyCode ] ;
85
+ this . properties . outputDir = arrowKeys [ e . keyCode ] ;
86
+ this . onPropertyChanged ( ) ;
87
+ this . keyCode = 0 ;
88
+ } else this . keyCode = e . keyCode ;
89
+ }
90
+
91
+ this . onDeselected = ( ) => { this . keyCode = 0 } ;
92
+
77
93
this . getExtraMenuOptions = function ( )
78
94
{
79
95
var that = this ;
@@ -94,7 +110,7 @@ app.registerExtension({
94
110
{ content :"⮠" , callback : function ( ) { that . properties . inputDir = "UP" ; that . properties . outputDir = "LEFT" ; that . onPropertyChanged ( ) ; } } ,
95
111
] ;
96
112
}
97
-
113
+
98
114
this . onPropertyChanged = function ( )
99
115
{
100
116
const aValues = [ "LEFT" , "RIGHT" , "UP" , "DOWN" , "TOP" ] ;
0 commit comments