Skip to content

Commit 9318f6f

Browse files
trigger on link change
1 parent 2cb078c commit 9318f6f

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/lib/litegraph/src/LGraphNode.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2852,7 +2852,17 @@ export class LGraphNode
28522852
output.links ??= []
28532853
output.links.push(link.id)
28542854
// connect in input
2855-
inputNode.inputs[inputIndex].link = link.id
2855+
const targetInput = inputNode.inputs[inputIndex]
2856+
targetInput.link = link.id
2857+
if (targetInput.widget) {
2858+
graph.trigger('node:slot-links:changed', {
2859+
nodeId: inputNode.id,
2860+
slotType: NodeSlotType.INPUT,
2861+
slotIndex: inputIndex,
2862+
connected: true,
2863+
linkId: link.id
2864+
})
2865+
}
28562866

28572867
// Reroutes
28582868
const reroutes = LLink.getReroutes(graph, link)
@@ -3009,6 +3019,15 @@ export class LGraphNode
30093019
const input = target.inputs[link_info.target_slot]
30103020
// remove there
30113021
input.link = null
3022+
if (input.widget) {
3023+
graph.trigger('node:slot-links:changed', {
3024+
nodeId: target.id,
3025+
slotType: NodeSlotType.INPUT,
3026+
slotIndex: link_info.target_slot,
3027+
connected: false,
3028+
linkId: link_info.id
3029+
})
3030+
}
30123031

30133032
// remove the link from the links pool
30143033
link_info.disconnect(graph, 'input')
@@ -3045,6 +3064,15 @@ export class LGraphNode
30453064
const input = target.inputs[link_info.target_slot]
30463065
// remove other side link
30473066
input.link = null
3067+
if (input.widget) {
3068+
graph.trigger('node:slot-links:changed', {
3069+
nodeId: target.id,
3070+
slotType: NodeSlotType.INPUT,
3071+
slotIndex: link_info.target_slot,
3072+
connected: false,
3073+
linkId: link_info.id
3074+
})
3075+
}
30483076

30493077
// link_info hasn't been modified so its ok
30503078
target.onConnectionsChange?.(
@@ -3114,6 +3142,15 @@ export class LGraphNode
31143142
const link_id = this.inputs[slot].link
31153143
if (link_id != null) {
31163144
this.inputs[slot].link = null
3145+
if (input.widget) {
3146+
graph.trigger('node:slot-links:changed', {
3147+
nodeId: this.id,
3148+
slotType: NodeSlotType.INPUT,
3149+
slotIndex: slot,
3150+
connected: false,
3151+
linkId: link_id
3152+
})
3153+
}
31173154

31183155
// remove other side
31193156
const link_info = graph._links.get(link_id)

0 commit comments

Comments
 (0)