Skip to content

Commit

Permalink
Allow backspace key to remove last point while editing
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvdo committed Mar 16, 2021
1 parent 1ccabc3 commit d3274a6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/yeti/SubPanelCourse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,19 @@
</div>
</div>
<div class="yetiform-note mt-5">
<p>Astuces</p>
<p>Astuces de dessin</p>
<ul class="content-ul">
<li><strong>Dessinez</strong> de nouvelles portions de lignes</li>
<li><strong>Supprimez</strong> le dernier point avec la touche <kbd>Backspace</kbd></li>
</ul>
<p>Sur une ligne dessinée</p>
<ul class="content-ul">
<li><strong>Éditez</strong> les points en les déplaçant</li>
<li><strong>Créez</strong> un nouveau point sur une ligne existante</li>
<li><strong>Supprimez un point</strong> avec Alt + clic</li>
<li><strong>Supprimez un point</strong> avec <kbd>Alt + clic</kbd></li>
</ul>
<p>Depuis l’interface</p>
<ul class="content-ul">
<li><strong>Supprimez une portion de ligne</strong></li>
<li><strong>Supprimez la trace</strong> pour en charger une nouvelle</li>
</ul>
Expand Down
19 changes: 19 additions & 0 deletions src/components/yeti/YetiMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export default {
this.snapInteraction = new ol.interaction.Snap({ source });
this.map.addInteraction(this.snapInteraction);
this.drawInteraction.on('drawstart', this.onDrawStart);
this.drawInteraction.on('drawend', this.onDrawEnd);
this.modifyInteraction.on('modifyend', this.onModifyEnd);
Expand Down Expand Up @@ -442,10 +443,28 @@ export default {
}
},
onDrawStart() {
document.addEventListener('keydown', this.onKeyWhileDrawing);
document.addEventListener('keypress', this.onKeyWhileDrawing);
},
onDrawEnd() {
document.removeEventListener('keydown', this.onKeyWhileDrawing);
document.removeEventListener('keypress', this.onKeyWhileDrawing);
},
onModifyEnd() {
this.emitFeaturesEvent();
},
onKeyWhileDrawing(event) {
event.preventDefault();
// backspace key
if (event.key === 'Backspace') {
this.drawInteraction.removeLastPoint();
}
},
drawYetiImage() {
const xml = new DOMParser().parseFromString(this.computedData, 'application/xml');
const imageBase64 = xml.getElementsByTagName('wps:ComplexData')[0].textContent;
Expand Down

0 comments on commit d3274a6

Please sign in to comment.