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

Method processMouseDown

src/LGraphCanvas.ts:1942–2051  ·  view source on GitHub ↗
(e: PointerEvent)

Source from the content-addressed store, hash-verified

1940 }
1941
1942 processMouseDown(e: PointerEvent): void {
1943 if (this.dragZoomEnabled && e.ctrlKey && e.shiftKey && !e.altKey && e.buttons) {
1944 this.#dragZoomStart = { pos: [e.x, e.y], scale: this.ds.scale }
1945 return
1946 }
1947
1948 const { graph, pointer } = this
1949 this.adjustMouseEvent(e)
1950 if (e.isPrimary) pointer.down(e)
1951
1952 if (this.set_canvas_dirty_on_mouse_event) this.dirty_canvas = true
1953
1954 if (!graph) return
1955
1956 const ref_window = this.getCanvasWindow()
1957 LGraphCanvas.active_canvas = this
1958
1959 const x = e.clientX
1960 const y = e.clientY
1961 this.ds.viewport = this.viewport
1962 const is_inside = !this.viewport || isInRect(x, y, this.viewport)
1963
1964 if (!is_inside) return
1965
1966 const node = graph.getNodeOnPos(e.canvasX, e.canvasY, this.visible_nodes) ?? undefined
1967
1968 this.mouse[0] = x
1969 this.mouse[1] = y
1970 this.graph_mouse[0] = e.canvasX
1971 this.graph_mouse[1] = e.canvasY
1972 this.last_click_position = [this.mouse[0], this.mouse[1]]
1973
1974 pointer.isDouble = pointer.isDown && e.isPrimary
1975 pointer.isDown = true
1976
1977 this.canvas.focus()
1978
1979 LiteGraph.closeAllContextMenus(ref_window)
1980
1981 if (this.onMouse?.(e) == true) return
1982
1983 // left button mouse / single finger
1984 if (e.button === 0 && !pointer.isDouble) {
1985 this.#processPrimaryButton(e, node)
1986 } else if (e.button === 1) {
1987 this.#processMiddleButton(e, node)
1988 } else if (
1989 (e.button === 2 || pointer.isDouble) &&
1990 this.allow_interaction &&
1991 !this.read_only
1992 ) {
1993 // Right / aux button
1994 const { linkConnector, subgraph } = this
1995
1996 // Sticky select - won't remove single nodes
1997 if (subgraph?.inputNode.containsPoint(this.graph_mouse)) {
1998 // Subgraph input node
1999 this.processSelect(subgraph.inputNode, e, true)

Callers

nothing calls this directly

Calls 15

adjustMouseEventMethod · 0.95
getCanvasWindowMethod · 0.95
#processPrimaryButtonMethod · 0.95
#processMiddleButtonMethod · 0.95
processSelectMethod · 0.95
deselectMethod · 0.95
processContextMenuMethod · 0.95
isInRectFunction · 0.90
downMethod · 0.80
closeAllContextMenusMethod · 0.80
changeMethod · 0.80
onMouseDownMethod · 0.80

Tested by

no test coverage detected