Playing with a hotkeys + commands setup and config
This commit is contained in:
parent
d29f996e61
commit
b0706e5544
11
src/App.js
11
src/App.js
@ -23,8 +23,19 @@ import WhiteLabellingContext from './WhiteLabellingContext';
|
|||||||
import setupTools from './setupTools';
|
import setupTools from './setupTools';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
|
|
||||||
|
// Register all of our commands and hotkeys
|
||||||
|
import commands from './commands';
|
||||||
|
|
||||||
const { ExtensionManager } = OHIF.extensions;
|
const { ExtensionManager } = OHIF.extensions;
|
||||||
|
|
||||||
|
commands.init();
|
||||||
|
// window.config.userPreferences
|
||||||
|
Object.keys(window.config.hotkeys).forEach(commandName => {
|
||||||
|
const keys = window.config.hotkeys[commandName];
|
||||||
|
// OHIF.HotkeysManager.set();
|
||||||
|
OHIF.HotkeysManager.registerHotkeys(commandName, keys);
|
||||||
|
});
|
||||||
|
|
||||||
setupTools(store);
|
setupTools(store);
|
||||||
|
|
||||||
const children = {
|
const children = {
|
||||||
|
|||||||
@ -1,38 +1,38 @@
|
|||||||
import { HotkeysManager } from 'ohif-core';
|
// import { HotkeysManager } from 'ohif-core';
|
||||||
import store from './store';
|
// import store from './store';
|
||||||
|
|
||||||
function initialize() {
|
// function initialize() {
|
||||||
// binding, method,
|
// // binding, method,
|
||||||
const numHotkeys = hotkeyConfig.length;
|
// const numHotkeys = hotkeyConfig.length;
|
||||||
for (let i = 0; i < numHotkeys; i++) {
|
// for (let i = 0; i < numHotkeys; i++) {
|
||||||
const { keys, actionName, actionContexts, options } = hotkeyConfig[i];
|
// const { keys, actionName, actionContexts, options } = hotkeyConfig[i];
|
||||||
const action = actions[actionName];
|
// const action = actions[actionName];
|
||||||
|
|
||||||
Mousetrap.bind(keys, () => {
|
// Mousetrap.bind(keys, () => {
|
||||||
let actionParams = options;
|
// let actionParams = options;
|
||||||
actionContexts.forEach(context => {
|
// actionContexts.forEach(context => {
|
||||||
actionParams[context] = store.getState()[context];
|
// actionParams[context] = store.getState()[context];
|
||||||
});
|
// });
|
||||||
action(actionParams);
|
// action(actionParams);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const hotkeysPreferences = store.getState().preferences;
|
// const hotkeysPreferences = store.getState().preferences;
|
||||||
const hotkeysViewerContext = hotkeysPreferences.viewer;
|
// const hotkeysViewerContext = hotkeysPreferences.viewer;
|
||||||
const hotkeysData = hotkeysViewerContext.hotkeysData;
|
// const hotkeysData = hotkeysViewerContext.hotkeysData;
|
||||||
|
|
||||||
Object.keys(hotkeysData).forEach(hotkeyName => {
|
// Object.keys(hotkeysData).forEach(hotkeyName => {
|
||||||
// context,
|
// // context,
|
||||||
const hotkeyCommandName = hotkeysData[hotkeyName];
|
// const hotkeyCommandName = hotkeysData[hotkeyName];
|
||||||
HotkeysManager.register();
|
// HotkeysManager.register();
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
function clear() {
|
// function clear() {
|
||||||
HotkeysManager.clear();
|
// HotkeysManager.clear();
|
||||||
}
|
// }
|
||||||
|
|
||||||
export default {
|
// export default {
|
||||||
clear,
|
// clear,
|
||||||
initialize,
|
// initialize,
|
||||||
};
|
// };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user