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

Method #processPrimaryButton

src/LGraphCanvas.ts:2075–2321  ·  view source on GitHub ↗
(e: CanvasPointerEvent, node: LGraphNode | undefined)

Source from the content-addressed store, hash-verified

2073 }
2074
2075 #processPrimaryButton(e: CanvasPointerEvent, node: LGraphNode | undefined) {
2076 const { pointer, graph, linkConnector, subgraph } = this
2077 if (!graph) throw new NullGraphError()
2078
2079 const x = e.canvasX
2080 const y = e.canvasY
2081
2082 // Modifiers
2083 const ctrlOrMeta = e.ctrlKey || e.metaKey
2084
2085 // Multi-select drag rectangle
2086 if (ctrlOrMeta && !e.altKey && LiteGraph.canvasNavigationMode === "legacy") {
2087 this.#setupNodeSelectionDrag(e, pointer, node)
2088
2089 return
2090 }
2091
2092 if (this.read_only) {
2093 pointer.finally = () => this.dragging_canvas = false
2094 this.dragging_canvas = true
2095 return
2096 }
2097
2098 // clone node ALT dragging
2099 if (LiteGraph.alt_drag_do_clone_nodes && e.altKey && !e.ctrlKey && node && this.allow_interaction) {
2100 let newType = node.type
2101
2102 if (node instanceof SubgraphNode) {
2103 const cloned = node.subgraph
2104 .clone()
2105 .asSerialisable()
2106
2107 const subgraph = graph.createSubgraph(cloned)
2108 subgraph.configure(cloned)
2109 newType = subgraph.id
2110 }
2111
2112 const node_data = node.clone()?.serialize()
2113 if (node_data?.type != null) {
2114 const cloned = LiteGraph.createNode(newType)
2115 if (cloned) {
2116 cloned.configure(node_data)
2117 cloned.pos[0] += 5
2118 cloned.pos[1] += 5
2119
2120 if (this.allow_dragnodes) {
2121 pointer.onDragStart = (pointer) => {
2122 graph.add(cloned, false)
2123 this.#startDraggingItems(cloned, pointer)
2124 }
2125 pointer.onDragEnd = e => this.#processDraggedItems(e)
2126 } else {
2127 // TODO: Check if before/after change are necessary here.
2128 graph.beforeChange()
2129 graph.add(cloned, false)
2130 graph.afterChange()
2131 }
2132

Callers 1

processMouseDownMethod · 0.95

Calls 15

#startDraggingItemsMethod · 0.95
#processDraggedItemsMethod · 0.95
#processNodeClickMethod · 0.95
processSelectMethod · 0.95
#linkConnectorDropMethod · 0.95
showLinkMenuMethod · 0.95
emitEventMethod · 0.95
showSearchBoxMethod · 0.95
isInRectangleFunction · 0.90
snapPointFunction · 0.90
createSubgraphMethod · 0.80

Tested by

no test coverage detected