diff options
author | bobzel <zzzman@gmail.com> | 2021-10-01 11:30:45 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2021-10-01 11:30:45 -0400 |
commit | cc5294616936c5e8a3a09f51fba4e6e89ce2c26c (patch) | |
tree | c179d3ca1ba98fd2d0f723c18a9c9dbf2e0ba1a8 | |
parent | 24014ab70a7ef8294239addbea21ced76861b435 (diff) |
fixed keyboard delete of ink control points to never delete the stroke.
-rw-r--r-- | src/client/views/InkControlPtHandles.tsx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/client/views/InkControlPtHandles.tsx b/src/client/views/InkControlPtHandles.tsx index 94c238b2b..0644488b3 100644 --- a/src/client/views/InkControlPtHandles.tsx +++ b/src/client/views/InkControlPtHandles.tsx @@ -28,6 +28,13 @@ export class InkControlPtHandles extends React.Component<InkControlProps> { @observable private _overControl = -1; @observable controlUndo: UndoManager.Batch | undefined; + + componentDidMount() { + document.addEventListener("keydown", this.onDelete, true); + } + componentWillUnmount() { + document.removeEventListener("keydown", this.onDelete, true); + } /** * Handles the movement of a selected control point when the user clicks and drags. * @param controlIndex The index of the currently selected control point. @@ -91,7 +98,8 @@ export class InkControlPtHandles extends React.Component<InkControlProps> { @action onDelete = (e: KeyboardEvent) => { if (["-", "Backspace", "Delete"].includes(e.key)) { - if (InkStrokeProperties.Instance?.deletePoints()) e.stopPropagation(); + InkStrokeProperties.Instance?.deletePoints(); + e.stopPropagation(); } } @@ -102,7 +110,6 @@ export class InkControlPtHandles extends React.Component<InkControlProps> { changeCurrPoint = (i: number) => { if (InkStrokeProperties.Instance) { InkStrokeProperties.Instance._currentPoint = i; - document.addEventListener("keydown", this.onDelete, true); } } |