Skip to content

Commit 690f6d2

Browse files
[refactor] rename canCapturePointerEvents to shouldHandleNodePointerEvents - addresses review feedback
Improves naming clarity by making it explicit that this controls whether Vue node components should handle pointer events rather than forward them to the canvas during panning mode. Co-authored-by: DrJKL <[email protected]>
1 parent e0b76ce commit 690f6d2

File tree

5 files changed

+29
-28
lines changed

5 files changed

+29
-28
lines changed

src/renderer/core/canvas/useCanvasInteractions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export function useCanvasInteractions() {
1919
)
2020

2121
/**
22-
* Whether Vue components can capture pointer events.
23-
* Returns false when canvas is in read-only/panning mode.
22+
* Whether Vue node components should handle pointer events.
23+
* Returns false when canvas is in read-only/panning mode (e.g., space key held for panning).
2424
*/
25-
const canCapturePointerEvents = computed(
25+
const shouldHandleNodePointerEvents = computed(
2626
() => !(canvasStore.canvas?.read_only ?? false)
2727
)
2828

@@ -107,6 +107,6 @@ export function useCanvasInteractions() {
107107
handleWheel,
108108
handlePointer,
109109
forwardEventToCanvas,
110-
canCapturePointerEvents
110+
shouldHandleNodePointerEvents
111111
}
112112
}

src/renderer/extensions/vueNodes/components/LGraphNode.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
'border border-solid border-sand-100 dark-theme:border-charcoal-300',
1414
!!executing && 'border-blue-100 dark-theme:border-blue-100',
1515
hasAnyError && 'border-error',
16-
// hover (only when events can be captured)
17-
canCapturePointerEvents &&
16+
// hover (only when node should handle events)
17+
shouldHandleNodePointerEvents &&
1818
'hover:ring-7 ring-gray-500/50 dark-theme:ring-gray-500/20',
1919
// Selected
2020
'outline-transparent -outline-offset-2 outline-2',
@@ -28,7 +28,7 @@
2828
'will-change-transform': isDragging
2929
},
3030
lodCssClass,
31-
canCapturePointerEvents ? 'pointer-events-auto' : 'pointer-events-none'
31+
shouldHandleNodePointerEvents ? 'pointer-events-auto' : 'pointer-events-none'
3232
)
3333
"
3434
:style="[
@@ -246,7 +246,7 @@ const {
246246
handleWheel,
247247
handlePointer,
248248
forwardEventToCanvas,
249-
canCapturePointerEvents
249+
shouldHandleNodePointerEvents
250250
} = useCanvasInteractions()
251251
252252
// LOD (Level of Detail) system based on zoom level
@@ -343,8 +343,8 @@ const handlePointerDown = (event: PointerEvent) => {
343343
return
344344
}
345345
346-
// Don't capture pointer events when canvas is in panning mode - forward to canvas instead
347-
if (!canCapturePointerEvents.value) {
346+
// Don't handle pointer events when canvas is in panning mode - forward to canvas instead
347+
if (!shouldHandleNodePointerEvents.value) {
348348
forwardEventToCanvas(event)
349349
return
350350
}
@@ -372,7 +372,7 @@ const handlePointerUp = (event: PointerEvent) => {
372372
}
373373
374374
// Don't emit node-click when canvas is in panning mode - forward to canvas instead
375-
if (!canCapturePointerEvents.value) {
375+
if (!shouldHandleNodePointerEvents.value) {
376376
forwardEventToCanvas(event)
377377
return
378378
}
@@ -401,7 +401,7 @@ const handleSlotClick = (
401401
}
402402
403403
// Don't handle slot clicks when canvas is in panning mode
404-
if (!canCapturePointerEvents.value) {
404+
if (!shouldHandleNodePointerEvents.value) {
405405
return
406406
}
407407

src/renderer/extensions/vueNodes/components/NodeWidgets.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
</div>
55
<div
66
v-else
7-
:class="[
7+
:class="cn(
88
'lg-node-widgets flex flex-col gap-2 pr-4',
9-
canCapturePointerEvents ? 'pointer-events-auto' : 'pointer-events-none'
10-
]"
9+
shouldHandleNodePointerEvents ? 'pointer-events-auto' : 'pointer-events-none'
10+
)"
1111
@pointerdown="handleWidgetPointerEvent"
1212
@pointermove="handleWidgetPointerEvent"
1313
@pointerup="handleWidgetPointerEvent"
@@ -65,6 +65,7 @@ import {
6565
shouldRenderAsVue
6666
} from '@/renderer/extensions/vueNodes/widgets/registry/widgetRegistry'
6767
import type { SimplifiedWidget, WidgetValue } from '@/types/simplifiedWidget'
68+
import { cn } from '@/utils/tailwindUtil'
6869
6970
import InputSlot from './InputSlot.vue'
7071
@@ -77,10 +78,10 @@ interface NodeWidgetsProps {
7778
7879
const props = defineProps<NodeWidgetsProps>()
7980
80-
const { canCapturePointerEvents, forwardEventToCanvas } =
81+
const { shouldHandleNodePointerEvents, forwardEventToCanvas } =
8182
useCanvasInteractions()
8283
const handleWidgetPointerEvent = (event: PointerEvent) => {
83-
if (!canCapturePointerEvents.value) {
84+
if (!shouldHandleNodePointerEvents.value) {
8485
forwardEventToCanvas(event)
8586
}
8687
}

src/renderer/extensions/vueNodes/composables/useNodeEventHandlers.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface NodeManager {
2222
export function useNodeEventHandlers(nodeManager: Ref<NodeManager | null>) {
2323
const canvasStore = useCanvasStore()
2424
const { bringNodeToFront } = useNodeZIndex()
25-
const { canCapturePointerEvents } = useCanvasInteractions()
25+
const { shouldHandleNodePointerEvents } = useCanvasInteractions()
2626

2727
/**
2828
* Handle node selection events
@@ -33,7 +33,7 @@ export function useNodeEventHandlers(nodeManager: Ref<NodeManager | null>) {
3333
nodeData: VueNodeData,
3434
wasDragging: boolean
3535
) => {
36-
if (!canCapturePointerEvents.value) return
36+
if (!shouldHandleNodePointerEvents.value) return
3737

3838
if (!canvasStore.canvas || !nodeManager.value) return
3939

@@ -73,7 +73,7 @@ export function useNodeEventHandlers(nodeManager: Ref<NodeManager | null>) {
7373
* Uses LiteGraph's native collapse method for proper state management
7474
*/
7575
const handleNodeCollapse = (nodeId: string, collapsed: boolean) => {
76-
if (!canCapturePointerEvents.value) return
76+
if (!shouldHandleNodePointerEvents.value) return
7777

7878
if (!nodeManager.value) return
7979

@@ -92,7 +92,7 @@ export function useNodeEventHandlers(nodeManager: Ref<NodeManager | null>) {
9292
* Updates the title in LiteGraph for persistence across sessions
9393
*/
9494
const handleNodeTitleUpdate = (nodeId: string, newTitle: string) => {
95-
if (!canCapturePointerEvents.value) return
95+
if (!shouldHandleNodePointerEvents.value) return
9696

9797
if (!nodeManager.value) return
9898

@@ -111,7 +111,7 @@ export function useNodeEventHandlers(nodeManager: Ref<NodeManager | null>) {
111111
event: PointerEvent,
112112
nodeData: VueNodeData
113113
) => {
114-
if (!canCapturePointerEvents.value) return
114+
if (!shouldHandleNodePointerEvents.value) return
115115

116116
if (!canvasStore.canvas || !nodeManager.value) return
117117

@@ -133,7 +133,7 @@ export function useNodeEventHandlers(nodeManager: Ref<NodeManager | null>) {
133133
* Integrates with LiteGraph's context menu system
134134
*/
135135
const handleNodeRightClick = (event: PointerEvent, nodeData: VueNodeData) => {
136-
if (!canCapturePointerEvents.value) return
136+
if (!shouldHandleNodePointerEvents.value) return
137137

138138
if (!canvasStore.canvas || !nodeManager.value) return
139139

@@ -157,7 +157,7 @@ export function useNodeEventHandlers(nodeManager: Ref<NodeManager | null>) {
157157
* Prepares node for dragging and sets appropriate visual state
158158
*/
159159
const handleNodeDragStart = (event: DragEvent, nodeData: VueNodeData) => {
160-
if (!canCapturePointerEvents.value) return
160+
if (!shouldHandleNodePointerEvents.value) return
161161

162162
if (!canvasStore.canvas || !nodeManager.value) return
163163

@@ -187,7 +187,7 @@ export function useNodeEventHandlers(nodeManager: Ref<NodeManager | null>) {
187187
* Useful for selection toolbox or area selection
188188
*/
189189
const selectNodes = (nodeIds: string[], addToSelection = false) => {
190-
if (!canCapturePointerEvents.value) return
190+
if (!shouldHandleNodePointerEvents.value) return
191191

192192
if (!canvasStore.canvas || !nodeManager.value) return
193193

@@ -209,7 +209,7 @@ export function useNodeEventHandlers(nodeManager: Ref<NodeManager | null>) {
209209
* Deselect specific nodes
210210
*/
211211
const deselectNodes = (nodeIds: string[]) => {
212-
if (!canCapturePointerEvents.value) return
212+
if (!shouldHandleNodePointerEvents.value) return
213213

214214
if (!canvasStore.canvas || !nodeManager.value) return
215215

tests-ui/tests/renderer/extensions/vueNodes/composables/useNodeEventHandlers.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ function createMockLayoutMutations(): Pick<
7575

7676
function createMockCanvasInteractions(): Pick<
7777
ReturnType<typeof useCanvasInteractions>,
78-
'canCapturePointerEvents'
78+
'shouldHandleNodePointerEvents'
7979
> {
8080
return {
81-
canCapturePointerEvents: computed(() => true) // Default to allowing pointer events
81+
shouldHandleNodePointerEvents: computed(() => true) // Default to allowing pointer events
8282
}
8383
}
8484

0 commit comments

Comments
 (0)