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:
filtered
2025-04-06 23:31:09 +10:00
committed by GitHub
parent c77082fe2f
commit 7360e09172
2 changed files with 14 additions and 15 deletions

View File

@@ -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]

View File

@@ -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()
}
}
}