Skip to content

Commit 809acb9

Browse files
trigger on link change
1 parent 2fb4703 commit 809acb9

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
@@ -2840,7 +2840,17 @@ export class LGraphNode
28402840
output.links ??= []
28412841
output.links.push(link.id)
28422842
// connect in input
2843-
inputNode.inputs[inputIndex].link = link.id
2843+
const targetInput = inputNode.inputs[inputIndex]
2844+
targetInput.link = link.id
2845+
if (targetInput.widget) {
2846+
graph.trigger('node:slot-links:changed', {
2847+
nodeId: inputNode.id,
2848+
slotType: NodeSlotType.INPUT,
2849+
slotIndex: inputIndex,
2850+
connected: true,
2851+
linkId: link.id
2852+
})
2853+
}
28442854

28452855
// Reroutes
28462856
const reroutes = LLink.getReroutes(graph, link)
@@ -2997,6 +3007,15 @@ export class LGraphNode
29973007
const input = target.inputs[link_info.target_slot]
29983008
// remove there
29993009
input.link = null
3010+
if (input.widget) {
3011+
graph.trigger('node:slot-links:changed', {
3012+
nodeId: target.id,
3013+
slotType: NodeSlotType.INPUT,
3014+
slotIndex: link_info.target_slot,
3015+
connected: false,
3016+
linkId: link_info.id
3017+
})
3018+
}
30003019

30013020
// remove the link from the links pool
30023021
link_info.disconnect(graph, 'input')
@@ -3033,6 +3052,15 @@ export class LGraphNode
30333052
const input = target.inputs[link_info.target_slot]
30343053
// remove other side link
30353054
input.link = null
3055+
if (input.widget) {
3056+
graph.trigger('node:slot-links:changed', {
3057+
nodeId: target.id,
3058+
slotType: NodeSlotType.INPUT,
3059+
slotIndex: link_info.target_slot,
3060+
connected: false,
3061+
linkId: link_info.id
3062+
})
3063+
}
30363064

30373065
// link_info hasn't been modified so its ok
30383066
target.onConnectionsChange?.(
@@ -3102,6 +3130,15 @@ export class LGraphNode
31023130
const link_id = this.inputs[slot].link
31033131
if (link_id != null) {
31043132
this.inputs[slot].link = null
3133+
if (input.widget) {
3134+
graph.trigger('node:slot-links:changed', {
3135+
nodeId: this.id,
3136+
slotType: NodeSlotType.INPUT,
3137+
slotIndex: slot,
3138+
connected: false,
3139+
linkId: link_id
3140+
})
3141+
}
31053142

31063143
// remove other side
31073144
const link_info = graph._links.get(link_id)

0 commit comments

Comments
 (0)