Skip to content

Commit 2cb6302

Browse files
committed
Add keyboard shortcuts for creating annotation + selecting type
1 parent 09e0f90 commit 2cb6302

File tree

3 files changed

+68
-8
lines changed

3 files changed

+68
-8
lines changed

histomicsui/web_client/templates/panels/annotationSelector.pug

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ block content
7676
input#h-toggle-interactive(type='checkbox', checked=interactiveMode)
7777
| Interactive
7878
if accessLevel >= writeAccessLevel
79-
button.btn.btn-sm.btn-primary.h-create-annotation
80-
| #[span.icon-plus-squared] New
79+
label(title='Create a new annotation. Keyboard shortcut: n')
80+
button.btn.btn-sm.btn-primary.h-create-annotation
81+
| #[span.icon-plus-squared] New
8182
.clearfix

histomicsui/web_client/templates/panels/drawWidget.pug

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ block content
1515
.btn-group.btn-justified.btn-group-sm.h-draw-tools
1616
.btn-group.btn-group-sm
1717
button.h-draw.btn.btn-default(
18-
type='button', data-type='point', data-toggle='tooltip', title='Draw a new point', class=drawingType === 'point' ? 'active' : null)
18+
type='button', data-type='point', data-toggle='tooltip', title='Draw a new point (keyboard shortcut: o)', class=drawingType === 'point' ? 'active' : null)
1919
| #[span.icon-circle]Point
2020
.btn-group.btn-group-sm
2121
button.h-draw.btn.btn-default(
22-
type='button', data-type='rectangle', data-toggle='tooltip', title='Draw a new rectangle', class=drawingType === 'rectangle' ? 'active' : null)
22+
type='button', data-type='rectangle', data-toggle='tooltip', title='Draw a new rectangle (keyboard shortcut: r)', class=drawingType === 'rectangle' ? 'active' : null)
2323
| #[span.icon-check-empty]Rectangle
2424
.btn-group.btn-group-sm
2525
button.h-draw.btn.btn-default(
26-
type='button', data-type='ellipse', data-toggle='tooltip', title='Draw a new ellipse', class=drawingType === 'ellipse' ? 'active' : null)
26+
type='button', data-type='ellipse', data-toggle='tooltip', title='Draw a new ellipse (keyboard shortcut: i)', class=drawingType === 'ellipse' ? 'active' : null)
2727
| #[span.icon-circle-empty.flattenicon]Ellipse
2828
.btn-group.btn-group-sm
2929
button.h-draw.btn.btn-default(
30-
type='button', data-type='circle', data-toggle='tooltip', title='Draw a new circle', class=drawingType === 'circle' ? 'active' : null)
30+
type='button', data-type='circle', data-toggle='tooltip', title='Draw a new circle (keyboard shortcut: c)', class=drawingType === 'circle' ? 'active' : null)
3131
| #[span.icon-circle-empty]Circle
3232
.btn-group.btn-group-sm
3333
button.h-draw.btn.btn-default(
34-
type='button', data-type='polygon', data-toggle='tooltip', title='Draw a new polygon', class=drawingType === 'polygon' ? 'active' : null)
34+
type='button', data-type='polygon', data-toggle='tooltip', title='Draw a new polygon (keyboard shortcut: p)', class=drawingType === 'polygon' ? 'active' : null)
3535
| #[span.icon-draw-polygon]Polygon
3636
.btn-group.btn-group-sm
3737
button.h-draw.btn.btn-default(
38-
type='button', data-type='line', data-toggle='tooltip', title='Draw a new line', class=drawingType === 'line' ? 'active' : null)
38+
type='button', data-type='line', data-toggle='tooltip', title='Draw a new line (keyboard shortcut: l)', class=drawingType === 'line' ? 'active' : null)
3939
| #[span.icon-pencil]Line
4040

4141
if elements.length

histomicsui/web_client/views/body/ImageView.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,65 @@ var ImageView = View.extend({
11031103
case 's':
11041104
this.annotationSelector.selectAnnotationByRegion();
11051105
break;
1106+
case 'n':
1107+
if (!this.annotationSelector._activeAnnotation) {
1108+
this.annotationSelector.createAnnotation();
1109+
}
1110+
break;
1111+
case 'o':
1112+
if (this.annotationSelector._activeAnnotation) {
1113+
if (this.drawWidget._drawingType === 'point') {
1114+
this.drawWidget.cancelDrawMode();
1115+
} else {
1116+
this.drawWidget.drawElement(undefined, 'point');
1117+
}
1118+
}
1119+
break;
1120+
case 'r':
1121+
if (this.annotationSelector._activeAnnotation) {
1122+
if (this.drawWidget._drawingType === 'rectangle') {
1123+
this.drawWidget.cancelDrawMode();
1124+
} else {
1125+
this.drawWidget.drawElement(undefined, 'rectangle');
1126+
}
1127+
}
1128+
break;
1129+
case 'i':
1130+
if (this.annotationSelector._activeAnnotation) {
1131+
if (this.drawWidget._drawingType === 'ellipse') {
1132+
this.drawWidget.cancelDrawMode();
1133+
} else {
1134+
this.drawWidget.drawElement(undefined, 'ellipse');
1135+
}
1136+
}
1137+
break;
1138+
case 'c':
1139+
if (this.annotationSelector._activeAnnotation) {
1140+
if (this.drawWidget._drawingType === 'circle') {
1141+
this.drawWidget.cancelDrawMode();
1142+
} else {
1143+
this.drawWidget.drawElement(undefined, 'circle');
1144+
}
1145+
}
1146+
break;
1147+
case 'p':
1148+
if (this.annotationSelector._activeAnnotation) {
1149+
if (this.drawWidget._drawingType === 'polygon') {
1150+
this.drawWidget.cancelDrawMode();
1151+
} else {
1152+
this.drawWidget.drawElement(undefined, 'polygon');
1153+
}
1154+
}
1155+
break;
1156+
case 'l':
1157+
if (this.annotationSelector._activeAnnotation) {
1158+
if (this.drawWidget._drawingType === 'line') {
1159+
this.drawWidget.cancelDrawMode();
1160+
} else {
1161+
this.drawWidget.drawElement(undefined, 'line');
1162+
}
1163+
}
1164+
break;
11061165
}
11071166
},
11081167

0 commit comments

Comments
 (0)