mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-06 08:00:05 +00:00
Standardise right-click behaviour (#894)
- Uses CanvasPointer click to open context menu (formerly occurred on `pointerdown`) - Frees up right-click & drag to be used by future features - Right-clicking a reroute now selects the reroute, using the same selection logic used for right-clicking nodes
This commit is contained in:
@@ -1877,10 +1877,16 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
// Right / aux button
|
||||
|
||||
// Sticky select - won't remove single nodes
|
||||
if (node) this.processSelect(node, e, true)
|
||||
if (node) {
|
||||
this.processSelect(node, e, true)
|
||||
} else if (this.links_render_mode !== LinkRenderType.HIDDEN_LINK) {
|
||||
// Reroutes
|
||||
const reroute = graph.getRerouteOnPos(e.canvasX, e.canvasY)
|
||||
if (reroute) this.processSelect(reroute, e, true)
|
||||
}
|
||||
|
||||
// Show context menu for the node or group under the pointer
|
||||
this.processContextMenu(node, e)
|
||||
pointer.onClick = () => this.processContextMenu(node, e)
|
||||
}
|
||||
|
||||
this.last_mouse = [x, y]
|
||||
|
||||
@@ -788,22 +788,15 @@ export class LiteGraphGlobal {
|
||||
return hex
|
||||
}
|
||||
|
||||
closeAllContextMenus(ref_window: Window): void {
|
||||
ref_window = ref_window || window
|
||||
|
||||
const elements = ref_window.document.querySelectorAll(".litecontextmenu")
|
||||
closeAllContextMenus(ref_window: Window = window): void {
|
||||
const elements = [...ref_window.document.querySelectorAll(".litecontextmenu")]
|
||||
if (!elements.length) return
|
||||
|
||||
const results = []
|
||||
for (const element of elements) {
|
||||
results.push(element)
|
||||
}
|
||||
|
||||
for (const result of results) {
|
||||
if ("close" in result && typeof result.close === "function") {
|
||||
result.close()
|
||||
} else if (result.parentNode) {
|
||||
result.remove()
|
||||
if ("close" in element && typeof element.close === "function") {
|
||||
element.close()
|
||||
} else {
|
||||
element.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user