Support on slot click listeners in vue (#7059)

Adds support for the `node.onInputDblClick` and `node.onInputClick`
callbacks in vue
- Fixes vue link drop code so that a link which is not dropped on the
canvas does not fallback to the dropped on canvas code.

![input-double-click_00001](https://github.com/user-attachments/assets/8b138a6e-e569-4a5d-b59a-cd688ff062e6)

Resolves #7037

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7059-Support-on-slot-click-listeners-in-vue-2bb6d73d3650812993fdef244e91683b)
by [Unito](https://www.unito.io)
This commit is contained in:
AustinMroz
2025-12-01 14:34:43 -08:00
committed by GitHub
parent 2c437acff6
commit 202dc3bbb2
5 changed files with 46 additions and 15 deletions

View File

@@ -6,9 +6,9 @@ import { useChainCallback } from '@/composables/functional/useChainCallback'
import { CanvasPointer } from '@/lib/litegraph/src/CanvasPointer'
import type { LGraphCanvas } from '@/lib/litegraph/src/LGraphCanvas'
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import type { CanvasPointerEvent } from '@/lib/litegraph/src/types/events'
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
import { augmentToCanvasPointerEvent } from '@/renderer/extensions/vueNodes/utils/eventUtils'
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
@@ -64,16 +64,10 @@ function draw() {
ctx.scale(scaleFactor, scaleFactor)
widgetInstance.draw?.(ctx, node, width, 1, height)
}
function translateEvent(e: PointerEvent): asserts e is CanvasPointerEvent {
if (!node) return
canvas.adjustMouseEvent(e)
canvas.graph_mouse[0] = e.offsetX + node.pos[0]
canvas.graph_mouse[1] = e.offsetY + node.pos[1]
}
//See LGraphCanvas.processWidgetClick
function handleDown(e: PointerEvent) {
if (!node || !widgetInstance || !pointer) return
translateEvent(e)
augmentToCanvasPointerEvent(e, node, canvas)
pointer.down(e)
if (widgetInstance.mouse)
pointer.onDrag = (e) =>
@@ -82,14 +76,14 @@ function handleDown(e: PointerEvent) {
canvas.processWidgetClick(e, node, widgetInstance, pointer)
}
function handleUp(e: PointerEvent) {
if (!pointer) return
translateEvent(e)
if (!pointer || !node) return
augmentToCanvasPointerEvent(e, node, canvas)
e.click_time = e.timeStamp - (pointer?.eDown?.timeStamp ?? 0)
pointer.up(e)
}
function handleMove(e: PointerEvent) {
if (!pointer) return
translateEvent(e)
if (!pointer || !node) return
augmentToCanvasPointerEvent(e, node, canvas)
pointer.move(e)
}
</script>