-
Notifications
You must be signed in to change notification settings - Fork 377
Select Vue Nodes After Drag #5863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e1703da
fbc47b3
2243f64
f9c8c26
3323013
7f9c6e4
043a34b
6df86b3
da8ee70
7dc615b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,24 @@ import { useVueNodeLifecycle } from '@/composables/graph/useVueNodeLifecycle' | |
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' | ||
import { useCanvasInteractions } from '@/renderer/core/canvas/useCanvasInteractions' | ||
import { useNodeZIndex } from '@/renderer/extensions/vueNodes/composables/useNodeZIndex' | ||
import { isLGraphNode } from '@/utils/litegraphUtil' | ||
|
||
/** | ||
* Check if multiple nodes are selected | ||
* Optimized to return early when 2+ nodes found | ||
*/ | ||
function hasMultipleNodesSelected(selectedItems: unknown[]): boolean { | ||
christian-byrne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let count = 0 | ||
for (let i = 0; i < selectedItems.length; i++) { | ||
if (isLGraphNode(selectedItems[i])) { | ||
count++ | ||
if (count >= 2) { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
|
||
function useNodeEventHandlersIndividual() { | ||
const canvasStore = useCanvasStore() | ||
|
@@ -26,11 +44,7 @@ function useNodeEventHandlersIndividual() { | |
* Handle node selection events | ||
* Supports single selection and multi-select with Ctrl/Cmd | ||
*/ | ||
const handleNodeSelect = ( | ||
event: PointerEvent, | ||
nodeData: VueNodeData, | ||
wasDragging: boolean | ||
) => { | ||
const handleNodeSelect = (event: PointerEvent, nodeData: VueNodeData) => { | ||
if (!shouldHandleNodePointerEvents.value) return | ||
|
||
if (!canvasStore.canvas || !nodeManager.value) return | ||
|
@@ -48,12 +62,14 @@ function useNodeEventHandlersIndividual() { | |
canvasStore.canvas.select(node) | ||
} | ||
} else { | ||
// If it wasn't a drag: single-select the node | ||
if (!wasDragging) { | ||
const selectedMultipleNodes = hasMultipleNodesSelected( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [architecture] medium Priority Issue: The new selection logic changes behavior - previously wasDragging prevented single selection after drag, now multiple selection status is checked instead |
||
canvasStore.selectedItems | ||
) | ||
if (!selectedMultipleNodes) { | ||
// Single-select the node | ||
canvasStore.canvas.deselectAll() | ||
canvasStore.canvas.select(node) | ||
} | ||
// Regular click -> single select | ||
} | ||
|
||
// Bring node to front when clicked (similar to LiteGraph behavior) | ||
|
@@ -122,7 +138,7 @@ function useNodeEventHandlersIndividual() { | |
// TODO: add custom double-click behavior here | ||
// For now, ensure node is selected | ||
if (!node.selected) { | ||
handleNodeSelect(event, nodeData, false) | ||
handleNodeSelect(event, nodeData) | ||
} | ||
} | ||
|
||
|
@@ -143,7 +159,7 @@ function useNodeEventHandlersIndividual() { | |
|
||
// Select the node if not already selected | ||
if (!node.selected) { | ||
handleNodeSelect(event, nodeData, false) | ||
handleNodeSelect(event, nodeData) | ||
} | ||
|
||
// Let LiteGraph handle the context menu | ||
|
@@ -170,7 +186,7 @@ function useNodeEventHandlersIndividual() { | |
metaKey: event.metaKey, | ||
bubbles: true | ||
}) | ||
handleNodeSelect(syntheticEvent, nodeData, false) | ||
handleNodeSelect(syntheticEvent, nodeData) | ||
} | ||
|
||
// Set drag data for potential drop operations | ||
|
Uh oh!
There was an error while loading. Please reload this page.