Skip to content

Commit bafdab8

Browse files
committed
Fix clicks near DOMWidgets being swallowed
Adds a method on canvas to indicate that pointer events should be passed Adds an onPointerDown on DOMWidgets to call this method
1 parent b5d3cfd commit bafdab8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/lib/litegraph/src/LGraphCanvas.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2851,6 +2851,12 @@ export class LGraphCanvas
28512851

28522852
this.dirty_canvas = true
28532853
}
2854+
passPointerEvent(pointer: CanvasPointer, node: LGraphNode): boolean {
2855+
pointer.onDragStart = () => this.#startDraggingItems(node, pointer)
2856+
pointer.onDragEnd = (e) => this.#processDraggedItems(e)
2857+
this.dirty_canvas = true
2858+
return true
2859+
}
28542860

28552861
#processWidgetClick(
28562862
e: CanvasPointerEvent,

src/scripts/domWidget.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import _ from 'es-toolkit/compat'
22
import { type Component, toRaw } from 'vue'
33

44
import { useChainCallback } from '@/composables/functional/useChainCallback'
5+
import type { CanvasPointer } from '@/lib/litegraph/src/CanvasPointer'
56
import {
7+
LGraphCanvas,
68
LGraphNode,
79
LegacyWidget,
810
LiteGraph
@@ -176,6 +178,13 @@ abstract class BaseDOMWidgetImpl<V extends object | string>
176178
}
177179
this.options.onDraw?.(this)
178180
}
181+
override onPointerDown(
182+
pointer: CanvasPointer,
183+
node: LGraphNode,
184+
canvas: LGraphCanvas
185+
): boolean {
186+
return canvas.passPointerEvent(pointer, node)
187+
}
179188

180189
override onRemove(): void {
181190
useDomWidgetStore().unregisterWidget(this.id)

0 commit comments

Comments
 (0)