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

Method onShowMenuNodeProperties

src/LGraphCanvas.ts:1131–1188  ·  view source on GitHub ↗

@param value Parameter is never used

(
    value: NodeProperty | undefined,
    options: unknown,
    e: MouseEvent,
    prev_menu: ContextMenu<string>,
    node: LGraphNode,
  )

Source from the content-addressed store, hash-verified

1129
1130 /** @param value Parameter is never used */
1131 static onShowMenuNodeProperties(
1132 value: NodeProperty | undefined,
1133 options: unknown,
1134 e: MouseEvent,
1135 prev_menu: ContextMenu<string>,
1136 node: LGraphNode,
1137 ): boolean | undefined {
1138 if (!node || !node.properties) return
1139
1140 const canvas = LGraphCanvas.active_canvas
1141 const ref_window = canvas.getCanvasWindow()
1142
1143 const entries: IContextMenuValue<string>[] = []
1144 for (const i in node.properties) {
1145 value = node.properties[i] !== undefined ? node.properties[i] : " "
1146 if (typeof value == "object")
1147 value = JSON.stringify(value)
1148 const info = node.getPropertyInfo(i)
1149 if (info.type == "enum" || info.type == "combo")
1150 value = LGraphCanvas.getPropertyPrintableValue(value, info.values)
1151
1152 // value could contain invalid html characters, clean that
1153 value = LGraphCanvas.decodeHTML(stringOrEmpty(value))
1154 entries.push({
1155 content:
1156 `<span class='property_name'>${info.label || i}</span>` +
1157 `<span class='property_value'>${value}</span>`,
1158 value: i,
1159 })
1160 }
1161 if (!entries.length) {
1162 return
1163 }
1164
1165 new LiteGraph.ContextMenu<string>(
1166 entries,
1167 {
1168 event: e,
1169 callback: inner_clicked,
1170 parentMenu: prev_menu,
1171 allow_html: true,
1172 node,
1173 },
1174 // @ts-expect-error Unused
1175 ref_window,
1176 )
1177
1178 function inner_clicked(this: ContextMenuDivElement, v: { value: any }) {
1179 if (!node) return
1180
1181 const rect = this.getBoundingClientRect()
1182 canvas.showEditPropertyValue(node, v.value, {
1183 position: [rect.left, rect.top],
1184 })
1185 }
1186
1187 return false
1188 }

Callers

nothing calls this directly

Calls 5

stringOrEmptyFunction · 0.90
getCanvasWindowMethod · 0.80
getPropertyInfoMethod · 0.80
decodeHTMLMethod · 0.80

Tested by

no test coverage detected