Skip to content

Commit

Permalink
Merge pull request #950 from biigle/keyboard-shortcut-last-annotation
Browse files Browse the repository at this point in the history
Add keyboard shortcut for last annotation
  • Loading branch information
mzur authored Nov 5, 2024
2 parents c13ef5c + 94e9913 commit 097d62c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions resources/assets/js/annotations/annotatorContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {CrossOriginError} from './stores/images';
import {debounce} from './../core/utils';
import {handleErrorResponse} from '../core/messages/store';
import {urlParams as UrlParams} from '../core/utils';
import Keyboard from '../core/keyboard';
/**
* View model for the annotator container
Expand Down Expand Up @@ -592,6 +593,10 @@ export default {
}
Messages.danger(`Invalid shape. ${shape} needs ${count} different points.`);
},
selectLastAnnotation() {
let lastAnnotation = this.annotations.reduce((lastAnnotated, a) => a.id > lastAnnotated.id ? a : lastAnnotated, { id: 0 });
this.handleSelectAnnotation(lastAnnotation);
}
},
watch: {
async imageId(id) {
Expand Down Expand Up @@ -742,6 +747,8 @@ export default {
this.openTab = openTab;
}
}
Keyboard.on('C', this.selectLastAnnotation, 0, this.listenerSet);
},
mounted() {
Events.$emit('annotations.map.init', this.$refs.canvas.map);
Expand Down
7 changes: 7 additions & 0 deletions resources/assets/js/videos/videoContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import VideoApi from './api/videos';
import VideoLabelsTab from './components/videoLabelsTab';
import VideoScreen from './components/videoScreen';
import VideoTimeline from './components/videoTimeline';
import Keyboard from '../core/keyboard';
import {handleErrorResponse} from '../core/messages/store';
import {urlParams as UrlParams} from '../core/utils';
Expand Down Expand Up @@ -673,6 +674,10 @@ export default {
}
Messages.danger(`Invalid shape. ${shape} needs ${count} different points.`);
},
selectLastAnnotation() {
let lastAnnotation = this.annotations.reduce((lastAnnotated, a) => a.id > lastAnnotated.id ? a : lastAnnotated, { id: 0 });
this.selectAnnotations([lastAnnotation], this.selectedAnnotations, lastAnnotation.startFrame);
}
},
watch: {
'settings.playbackRate'(rate) {
Expand Down Expand Up @@ -724,6 +729,8 @@ export default {
this.video.addEventListener('pause', this.updateVideoUrlParams);
this.video.addEventListener('seeked', this.updateVideoUrlParams);
Keyboard.on('C', this.selectLastAnnotation, 0, this.listenerSet);
if (Settings.has('openTab')) {
this.openTab = Settings.get('openTab');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
<td><kbd>p</kbd></td>
<td>Capture a screenshot</td>
</tr>
<tr>
<td><kbd>c</kbd></td>
<td>Select last created annotation</td>
</tr>
</tbody>
</table>

Expand Down
4 changes: 4 additions & 0 deletions resources/views/manual/tutorials/videos/shortcuts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@
<td><kbd>Esc</kbd></td>
<td>Cancel current action<br><small>e.g. drawing or moving an annotation</small></td>
</tr>
<tr>
<td><kbd>c</kbd></td>
<td>Select last created annotation</td>
</tr>
</tbody>
</table>

Expand Down

0 comments on commit 097d62c

Please sign in to comment.