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

Method showMenuNodeOptionalOutputs

src/LGraphCanvas.ts:1056–1128  ·  view source on GitHub ↗

@param _options Parameter is never used

(
    v: unknown,
    /** Unused - immediately overwritten */
    _options: INodeOutputSlot[],
    e: MouseEvent,
    prev_menu: ContextMenu<INodeSlotContextItem>,
    node: LGraphNode,
  )

Source from the content-addressed store, hash-verified

1054
1055 /** @param _options Parameter is never used */
1056 static showMenuNodeOptionalOutputs(
1057 v: unknown,
1058 /** Unused - immediately overwritten */
1059 _options: INodeOutputSlot[],
1060 e: MouseEvent,
1061 prev_menu: ContextMenu<INodeSlotContextItem>,
1062 node: LGraphNode,
1063 ): boolean | undefined {
1064 if (!node) return
1065
1066 const canvas = LGraphCanvas.active_canvas
1067
1068 let entries: (IContextMenuValue<INodeSlotContextItem> | null)[] = []
1069
1070 if (LiteGraph.do_add_triggers_slots && node.findOutputSlot("onExecuted") == -1) {
1071 entries.push({ content: "On Executed", value: ["onExecuted", LiteGraph.EVENT, { nameLocked: true }], className: "event" })
1072 }
1073 // add callback for modifing the menu elements onMenuNodeOutputs
1074 const retEntries = node.onMenuNodeOutputs?.(entries)
1075 if (retEntries) entries = retEntries
1076
1077 if (!entries.length) return
1078
1079 new LiteGraph.ContextMenu<INodeSlotContextItem>(
1080 entries,
1081 {
1082 event: e,
1083 callback: inner_clicked,
1084 parentMenu: prev_menu,
1085 node,
1086 },
1087 )
1088
1089 function inner_clicked(this: ContextMenuDivElement<INodeSlotContextItem>, v: IContextMenuValue<INodeSlotContextItem>, e: any, prev: any) {
1090 if (!node) return
1091
1092 // TODO: This is a static method, so the below "that" appears broken.
1093 if (v.callback) v.callback.call(this, node, v, e, prev)
1094
1095 if (!v.value) return
1096
1097 const value = v.value[1]
1098
1099 if (value &&
1100 (typeof value === "object" || Array.isArray(value))) {
1101 // submenu why?
1102 const entries = []
1103 for (const i in value) {
1104 entries.push({ content: i, value: value[i] })
1105 }
1106 new LiteGraph.ContextMenu(entries, {
1107 event: e,
1108 callback: inner_clicked,
1109 parentMenu: prev_menu,
1110 node,
1111 })
1112 return false
1113 }

Callers

nothing calls this directly

Calls 1

findOutputSlotMethod · 0.45

Tested by

no test coverage detected