mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-04 21:22:07 +00:00
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.  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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user