MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / addInput

Method addInput

src/LGraphNode.ts:1536–1553  ·  view source on GitHub ↗

* add a new input slot to use in this node * @param type string defining the input type ("vec3","number",...), it its a generic one use 0 * @param extra_info this can be used to have special properties of an input (label, color, position, etc)

(name: string, type: ISlotType, extra_info?: TProperties)

Source from the content-addressed store, hash-verified

1534 * @param extra_info this can be used to have special properties of an input (label, color, position, etc)
1535 */
1536 addInput<TProperties extends Partial<INodeInputSlot>>(name: string, type: ISlotType, extra_info?: TProperties): INodeInputSlot & TProperties {
1537 type ||= 0
1538
1539 const input = Object.assign(
1540 new NodeInputSlot({ name, type, link: null }, this),
1541 extra_info,
1542 )
1543
1544 this.inputs ||= []
1545 this.inputs.push(input)
1546 this.expandToFitContent()
1547
1548 this.onInputAdded?.(input)
1549 LiteGraph.registerNodeAndSlotType(this, type)
1550
1551 this.setDirtyCanvas(true, true)
1552 return input
1553 }
1554
1555 /**
1556 * remove an existing input slot

Calls 3

expandToFitContentMethod · 0.95
setDirtyCanvasMethod · 0.95

Tested by 1

createNodeWithWidgetFunction · 0.76