Skip to content

Commit

Permalink
update: move hotkeys config to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Aug 22, 2023
1 parent d241c76 commit bbb4d17
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/components/ThreeDEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,18 @@ export class ThreeDEditor extends React.Component {
});
};

// map of hotkeys to their handlers
keyConfig = {
o: this.handleToggleOrbitControls, // O toggle orbit controls
i: this.handleToggleInteractive, // I toggle interactive
b: this.handleToggleBonds, // B toggle bonds
c: this.handleToggleConventionalCell, // C toggle conventional cell
l: this.handleToggleLabels, // L toggle labels
r: this.handleResetViewer, // R reset viewer
e: this.toggleThreejsEditorModal, // E toggle threejs editor modal
d: this.handleToggleDistanceShown, // D toggle distance measurement
a: this.handleToggleAnglesShown, // A toggle angles measurement
x: this.handleDeleteConnection, // X delete connection
[settings.hotKeysConfig.toggleOrbitControls]: this.handleToggleOrbitControls,
[settings.hotKeysConfig.toggleInteractive]: this.handleToggleInteractive,
[settings.hotKeysConfig.toggleBonds]: this.handleToggleBonds,
[settings.hotKeysConfig.toggleConventionalCell]: this.handleToggleConventionalCell,
[settings.hotKeysConfig.toggleLabels]: this.handleToggleLabels,
[settings.hotKeysConfig.resetViewer]: this.handleResetViewer,
[settings.hotKeysConfig.toggleThreejsEditorModal]: this.toggleThreejsEditorModal,
[settings.hotKeysConfig.toggleDistanceShown]: this.handleToggleDistanceShown,
[settings.hotKeysConfig.toggleAnglesShown]: this.handleToggleAnglesShown,
[settings.hotKeysConfig.deleteConnection]: this.handleDeleteConnection,
};

addHotKeyListener() {
Expand Down
13 changes: 13 additions & 0 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,17 @@ export default {
bc2: [0x0000ff, 0x0000ff],
bc3: [0xffff00, 0x0000ff],
},

hotKeysConfig: {
toggleOrbitControls: "o",
toggleInteractive: "i",
toggleBonds: "b",
toggleConventionalCell: "c",
toggleLabels: "l",
resetViewer: "r",
toggleThreejsEditorModal: "e",
toggleDistanceShown: "d",
toggleAnglesShown: "a",
deleteConnection: "x",
},
};

0 comments on commit bbb4d17

Please sign in to comment.