Changeset 35648 for main


Ignore:
Timestamp:
2021-10-20T13:49:14+13:00 (2 years ago)
Author:
cstephen
Message:

Reset time edits when pressing Escape

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/WordTimingSelector.vue

    r35641 r35648  
    260260        myWord(newValue, oldValue) {
    261261            if (newValue.id === oldValue.id && this.shadowWords.length > 0) {
    262                 console.log(`New: ${newValue.id} | Old: ${oldValue.id}`);
    263262                return;
    264263            }
    265264
    266             console.log("Updating");
    267265            this.shadowWords = [];
    268266            for (const word of this.mySurroundingWords) {
     
    295293        },
    296294
     295        /**
     296         * @param {KeyboardEvent} event
     297         */
     298        onDocumentKeyDown(event) {
     299            if (event.code === "Escape") {
     300                this.onDocumentMouseUp(); // Cancel any edits that are in progress
     301                this.emitWordUpdates(this.shadowWords);
     302            }
     303        },
     304
    297305        onDocumentMouseMove(event) {
    298306            if (this.canAdjustWordStartTime) {
     
    313321            this.adjustWordStartTime(event.movementX);
    314322
    315             this.updateSurroundingWords();
     323            this.emitWordUpdates(this.mySurroundingWords);
    316324        },
    317325        onMaxHandleMouseMove(event) {
     
    322330            this.adjustWordEndTime(event.movementX);
    323331
    324             this.updateSurroundingWords();
     332            this.emitWordUpdates(this.mySurroundingWords);
    325333        },
    326334        onDocumentMouseUp() {
     
    420428        },
    421429
    422         updateSurroundingWords() {
    423             for (let i = 0; i < this.mySurroundingWords.length; i++) {
    424                 const updatedWord = this.convertMyWord(this.mySurroundingWords[i], this.surroundingWords[i]);
     430        emitWordUpdates(words) {
     431            for (let i = 0; i < words.length; i++) {
     432                const updatedWord = this.convertMyWord(words[i], this.surroundingWords[i]);
    425433                this.$emit("wordUpdated", i, updatedWord);
    426434            }
     
    438446        document.addEventListener("mousemove", this.onDocumentMouseMove);
    439447        document.addEventListener("mouseup", this.onDocumentMouseUp);
     448        document.addEventListener("keydown", this.onDocumentKeyDown);
    440449    },
    441450    beforeUnmount() {
    442451        document.removeEventListener("mousemove", this.onDocumentMouseMove);
    443452        document.removeEventListener("mouseup", this.onDocumentMouseUp);
     453        document.removeEventListener("keydown", this.onDocumentKeyDown);
    444454    }
    445455}
Note: See TracChangeset for help on using the changeset viewer.