Mercurial > gemma
changeset 5440:0fa20662ca66 marking-single-beam
Esc/click to stop operation.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 13 Jul 2021 15:22:37 +0200 |
parents | a857d6ae1264 |
children | 7d7b1bf53189 |
files | client/src/components/KeyboardHandler.vue |
diffstat | 1 files changed, 29 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/KeyboardHandler.vue Tue Jul 13 13:00:41 2021 +0200 +++ b/client/src/components/KeyboardHandler.vue Tue Jul 13 15:22:37 2021 +0200 @@ -1,7 +1,7 @@ <template> <transition name="fade"> <div class="notice" v-if="showNotice"> - <span>{{ noticeText }}</span> + <span @click="stopOperation">{{ noticeText }}</span> </div> </transition> </template> @@ -70,28 +70,37 @@ } } }, + methods: { + closeCompareView() { + this.$store.commit("fairwayprofile/additionalSurvey", null); + }, + stopDrawing() { + this.$store.commit("map/lineToolEnabled", false); + this.$store.commit("map/polygonToolEnabled", false); + this.$store.commit("map/cutToolEnabled", false); + this.$store.commit("map/setCurrentMeasurement", null); + this.openLayersMaps.forEach(m => { + m.getLayer("DRAWTOOL") + .getSource() + .clear(); + }); + }, + stopOperation() { + if ( + this.lineToolEnabled || + this.polygonToolEnabled || + this.cutToolEnabled + ) { + this.stopDrawing(); + } else if (this.paneSetup.includes("COMPARESURVEYS")) { + this.closeCompareView(); + } + } + }, mounted() { window.addEventListener("keydown", e => { // Escape - if (e.keyCode === 27) { - if ( - this.lineToolEnabled || - this.polygonToolEnabled || - this.cutToolEnabled - ) { - this.$store.commit("map/lineToolEnabled", false); - this.$store.commit("map/polygonToolEnabled", false); - this.$store.commit("map/cutToolEnabled", false); - this.$store.commit("map/setCurrentMeasurement", null); - this.openLayersMaps.forEach(m => { - m.getLayer("DRAWTOOL") - .getSource() - .clear(); - }); - } else if (this.paneSetup.includes("COMPARESURVEYS")) { - this.$store.commit("fairwayprofile/additionalSurvey", null); - } - } + if (e.key === "Esc" || e.key === "Escape") this.stopOperation(); }); } };