* Determines whether to select or deselect an item that has received a pointer event. Will deselect other nodes if * @param item Canvas item to select/deselect * @param e The MouseEvent to handle * @param sticky Prevents deselecting individual nodes (as used by aux/right-click) * @remar
(
item: TPositionable | null | undefined,
e: CanvasPointerEvent | undefined,
sticky: boolean = false,
)
| 3687 | * Accessibility: anyone using {@link mutli_select} always deselects when clicking empty space. |
| 3688 | */ |
| 3689 | processSelect<TPositionable extends Positionable = LGraphNode>( |
| 3690 | item: TPositionable | null | undefined, |
| 3691 | e: CanvasPointerEvent | undefined, |
| 3692 | sticky: boolean = false, |
| 3693 | ): void { |
| 3694 | const addModifier = e?.shiftKey |
| 3695 | const subtractModifier = e != null && (e.metaKey || e.ctrlKey) |
| 3696 | const eitherModifier = addModifier || subtractModifier |
| 3697 | const modifySelection = eitherModifier || this.multi_select |
| 3698 | |
| 3699 | if (!item) { |
| 3700 | if (!eitherModifier || this.multi_select) this.deselectAll() |
| 3701 | } else if (!item.selected || !this.selectedItems.has(item)) { |
| 3702 | if (!modifySelection) this.deselectAll(item) |
| 3703 | this.select(item) |
| 3704 | } else if (modifySelection && !sticky) { |
| 3705 | this.deselect(item) |
| 3706 | } else if (!sticky) { |
| 3707 | this.deselectAll(item) |
| 3708 | } else { |
| 3709 | return |
| 3710 | } |
| 3711 | this.onSelectionChange?.(this.selected_nodes) |
| 3712 | this.setDirty(true) |
| 3713 | } |
| 3714 | |
| 3715 | /** |
| 3716 | * Selects a {@link Positionable} item. |
no test coverage detected