@@ -16,9 +16,15 @@ export const defaultHotkeys = [
1616 id : "create_point" ,
1717 description : "Create a point" ,
1818 } ,
19+ {
20+ id : "create_bounding_box" ,
21+ description : "Create a bounding box" ,
22+ binding : "b" ,
23+ } ,
1924 {
2025 id : "pan_tool" ,
2126 description : "Select the Pan Tool" ,
27+ binding : "p" ,
2228 } ,
2329 {
2430 id : "create_polygon" ,
@@ -31,10 +37,12 @@ export const defaultHotkeys = [
3137 {
3238 id : "save_and_previous_sample" ,
3339 description : "Save and go to previous sample" ,
40+ binding : "a" ,
3441 } ,
3542 {
3643 id : "save_and_next_sample" ,
3744 description : "Save and go to next sample" ,
45+ binding : "d" ,
3846 } ,
3947 {
4048 id : "save_and_exit_sample" ,
@@ -48,7 +56,7 @@ export const defaultHotkeys = [
4856export const defaultKeyMap = { }
4957for ( const { id, binding } of defaultHotkeys ) defaultKeyMap [ id ] = binding
5058
51- export default ( { children , dispatch } ) => {
59+ export const useDispatchHotkeyHandlers = ( { dispatch } ) => {
5260 const handlers = useMemo (
5361 ( ) => ( {
5462 select_tool : ( ) => {
@@ -69,6 +77,12 @@ export default ({ children, dispatch }) => {
6977 selectedTool : "create-point" ,
7078 } )
7179 } ,
80+ create_bounding_box : ( ) => {
81+ dispatch ( {
82+ type : "SELECT_TOOL" ,
83+ selectedTool : "create-box" ,
84+ } )
85+ } ,
7286 pan_tool : ( ) => {
7387 dispatch ( {
7488 type : "SELECT_TOOL" ,
@@ -114,6 +128,11 @@ export default ({ children, dispatch }) => {
114128 } ) ,
115129 [ dispatch ]
116130 )
131+ return handlers
132+ }
133+
134+ export default ( { children, dispatch } ) => {
135+ const handlers = useDispatchHotkeyHandlers ( { dispatch } )
117136 return (
118137 < HotKeys allowChanges handlers = { handlers } >
119138 { children }
0 commit comments