Skip to content

Commit

Permalink
feat(front): Add keydown event for Lengthmeasurement (#466)
Browse files Browse the repository at this point in the history
Added the feature to cancel Lengthmeasurement like its possible in Areameasurement!
  • Loading branch information
pstowasser01 authored Oct 11, 2024
1 parent a526903 commit 3bfdcbf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/front/src/measurement/LengthMeasurement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,11 @@ export class LengthMeasurement
if (!viewerContainer) return;

viewerContainer.removeEventListener("pointermove", this.onMouseMove);
window.removeEventListener("keydown", this.onKeydown);

if (active) {
viewerContainer.addEventListener("pointermove", this.onMouseMove);
window.addEventListener("keydown", this.onKeydown);
}
}

Expand All @@ -314,4 +316,11 @@ export class LengthMeasurement
this._vertexPicker.get(this.world);
}
};

private onKeydown = (e: KeyboardEvent) => {
if (!this.enabled) return;
if (e.key === "Escape") {
this.cancelCreation();
}
};
}

0 comments on commit 3bfdcbf

Please sign in to comment.