* Processes a pointerdown event inside the bounds of a node. Part of processMouseDown. * @param e The pointerdown event * @param ctrlOrMeta Ctrl or meta key is pressed * @param node The node to process a click event for
(
e: CanvasPointerEvent,
ctrlOrMeta: boolean,
node: LGraphNode,
)
| 2345 | * @param node The node to process a click event for |
| 2346 | */ |
| 2347 | #processNodeClick( |
| 2348 | e: CanvasPointerEvent, |
| 2349 | ctrlOrMeta: boolean, |
| 2350 | node: LGraphNode, |
| 2351 | ): void { |
| 2352 | const { pointer, graph, linkConnector } = this |
| 2353 | if (!graph) throw new NullGraphError() |
| 2354 | |
| 2355 | const x = e.canvasX |
| 2356 | const y = e.canvasY |
| 2357 | |
| 2358 | pointer.onClick = () => this.processSelect(node, e) |
| 2359 | |
| 2360 | // Immediately bring to front |
| 2361 | if (!node.flags.pinned) { |
| 2362 | this.bringToFront(node) |
| 2363 | } |
| 2364 | |
| 2365 | // Collapse toggle |
| 2366 | const inCollapse = node.isPointInCollapse(x, y) |
| 2367 | if (inCollapse) { |
| 2368 | pointer.onClick = () => { |
| 2369 | node.collapse() |
| 2370 | this.setDirty(true, true) |
| 2371 | } |
| 2372 | } else if (!node.flags.collapsed) { |
| 2373 | const { inputs, outputs } = node |
| 2374 | |
| 2375 | // Outputs |
| 2376 | if (outputs) { |
| 2377 | for (const [i, output] of outputs.entries()) { |
| 2378 | const link_pos = node.getOutputPos(i) |
| 2379 | if (isInRectangle(x, y, link_pos[0] - 15, link_pos[1] - 10, 30, 20)) { |
| 2380 | // Drag multiple output links |
| 2381 | if (e.shiftKey && (output.links?.length || output._floatingLinks?.size)) { |
| 2382 | linkConnector.moveOutputLink(graph, output) |
| 2383 | this.#linkConnectorDrop() |
| 2384 | return |
| 2385 | } |
| 2386 | |
| 2387 | // New output link |
| 2388 | linkConnector.dragNewFromOutput(graph, node, output) |
| 2389 | this.#linkConnectorDrop() |
| 2390 | |
| 2391 | if (LiteGraph.shift_click_do_break_link_from) { |
| 2392 | if (e.shiftKey) { |
| 2393 | node.disconnectOutput(i) |
| 2394 | } |
| 2395 | } else if (LiteGraph.ctrl_alt_click_do_break_link) { |
| 2396 | if (ctrlOrMeta && e.altKey && !e.shiftKey) { |
| 2397 | node.disconnectOutput(i) |
| 2398 | } |
| 2399 | } |
| 2400 | |
| 2401 | // TODO: Move callbacks to the start of this closure (onInputClick is already correct). |
| 2402 | pointer.onDoubleClick = () => node.onOutputDblClick?.(i, e) |
| 2403 | pointer.onClick = () => node.onOutputClick?.(i, e) |
| 2404 |
no test coverage detected