From 8176b94970b86bd3c1669130f6fef2ccd70d0b84 Mon Sep 17 00:00:00 2001
From: vkalev <victor_kalev@brown.edu>
Date: Thu, 9 Dec 2021 17:40:21 -0500
Subject: changing cursor + adding entire ink deletion mode when 'Alt' is
 pressed

---
 .../collectionFreeForm/CollectionFreeFormView.tsx     | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index df690da49..bb1d560d6 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -646,7 +646,7 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P
         if (CurrentUserUtils.SelectedTool !== InkTool.None) {
             this._currPoint = { X: e.clientX, Y: e.clientY };
             // Erasing ink strokes if intersections occur.
-            this.eraseInkStrokes(this.getEraserIntersections());
+            this.eraseInkStrokes(e, this.getEraserIntersections());
         }
         if (InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE)) {
             if (this.props.isContentActive(true)) e.stopPropagation();
@@ -668,19 +668,22 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P
      * and deletes the original stroke.
      * @param eraserIntersections The intersections made by the eraser.
      */
-    eraseInkStrokes = (eraserIntersections: Intersection[]) => {
+    eraseInkStrokes = (e: PointerEvent, eraserIntersections: Intersection[]) => {
         eraserIntersections.forEach(intersect => {
             const ink = intersect.ink;
             if (ink && !this._deleteList.includes(ink)) {
                 this._deleteList.push(ink);
                 SetActiveInkWidth(StrCast(ink.rootDoc.strokeWidth?.toString()) || "1");
                 SetActiveInkColor(StrCast(ink.rootDoc.color?.toString()) || "black");
-                // create a new curve by appending all curves of the current segment together in order to render a single new stroke.
-                this.segmentInkStroke(ink, intersect.t ?? 0).forEach(segment =>
-                    GestureOverlay.Instance.dispatchGesture(GestureUtils.Gestures.Stroke,
-                        segment.reduce((data, curve) => [...data, ...curve.points
-                            .map(p => ink.ComponentView?.ptToScreen?.({ X: p.x, Y: p.y }) ?? { X: 0, Y: 0 })
-                        ], [] as PointData[])));
+                // Piecewise ink deletion mode if the 'Alt' is not held down.
+                if (!e.altKey) {
+                    // create a new curve by appending all curves of the current segment together in order to render a single new stroke.
+                    this.segmentInkStroke(ink, intersect.t ?? 0).forEach(segment =>
+                        GestureOverlay.Instance.dispatchGesture(GestureUtils.Gestures.Stroke,
+                            segment.reduce((data, curve) => [...data, ...curve.points
+                                .map(p => ink.ComponentView?.ptToScreen?.({ X: p.x, Y: p.y }) ?? { X: 0, Y: 0 })
+                            ], [] as PointData[])));
+                }
                 // Lower ink opacity to give the user a visual indicator of deletion.
                 ink.layoutDoc.opacity = 0.5;
             }
-- 
cgit v1.2.3-70-g09d2

