Change HotkeyDefinition to include label

This commit is contained in:
dannyrb 2019-06-05 21:29:50 -04:00
parent 347680fdf5
commit 49fe195089
2 changed files with 46 additions and 41 deletions

View File

@ -19,44 +19,56 @@ window.config = {
}, },
], ],
}, },
// /**
userPreferences: [ * This maps registered commands to default hotkey values.
{ */
order: 0, hotkeys: [
title: 'preference page title',
items: [
{
order: 0,
label: 'Scale Viewport Up',
command: 'scaleUpViewport',
},
],
},
],
//
hotkeys: {
// ~ Global // ~ Global
incrementActiveViewport: ['right'], {
decrementActiveViewport: ['left'], commandName: 'incrementActiveViewport',
label: 'Next Image Viewport',
keys: ['right'],
},
{
commandName: 'decrementActiveViewport',
label: 'Previous Image Viewport',
keys: ['left'],
},
// Supported Keys: https://craig.is/killing/mice // Supported Keys: https://craig.is/killing/mice
// ~ Cornerstone Extension // ~ Cornerstone Extension
rotateViewportCW: ['r'], { commandName: 'rotateViewportCW', label: 'Rotate Right', keys: ['r'] },
rotateViewportCCW: ['l'], { commandName: 'rotateViewportCCW', label: 'Rotate Left', keys: ['l'] },
invertViewport: ['i'], { commandName: 'invertViewport', label: 'Invert', keys: ['i'] },
flipViewportVertical: ['h'], {
flipViewportHorizontal: ['v'], commandName: 'flipViewportVertical',
scaleUpViewport: ['+'], label: 'Flip Horizontally',
scaleDownViewport: ['-'], keys: ['h'],
fitViewportToWindow: ['='], },
resetViewport: ['space'], {
commandName: 'flipViewportHorizontal',
label: 'Flip Vertically',
keys: ['v'],
},
{ commandName: 'scaleUpViewport', label: 'Zoom In', keys: ['+'] },
{ commandName: 'scaleDownViewport', label: 'Zoom Out', keys: ['-'] },
{ commandName: 'fitViewportToWindow', label: 'Zoom to Fit', keys: ['='] },
{ commandName: 'resetViewport', label: 'Reset', keys: ['space'] },
// clearAnnotations // clearAnnotations
// nextImage // nextImage
// previousImage // previousImage
// firstImage // firstImage
// lastImage // lastImage
nextViewportDisplaySet: ['pageup'], {
previousViewportDisplaySet: ['pagedown'], commandName: 'nextViewportDisplaySet',
// ~ Cornerstone Tools label: 'Previous Series',
setZoomTool: ['z'], keys: ['pagedown'],
}, },
{
commandName: 'previousViewportDisplaySet',
label: 'Next Series',
keys: ['pageup'],
},
// ~ Cornerstone Tools
{ commandName: 'setZoomTool', label: 'Zoom', keys: ['z'] },
],
}; };

View File

@ -40,16 +40,9 @@ const _commandsManager = new CommandsManager(commandsManagerConfig);
const _hotkeysManager = new HotkeysManager(_commandsManager); const _hotkeysManager = new HotkeysManager(_commandsManager);
// TODO: Should be done in extensions w/ commandsModule // TODO: Should be done in extensions w/ commandsModule
// ADD COMMANDS // ~~ ADD COMMANDS
appCommands.init(_commandsManager); appCommands.init(_commandsManager);
_hotkeysManager.setHotkeys(window.config.hotkeys, true);
// window.config.userPreferences
Object.keys(window.config.hotkeys).forEach(commandName => {
const keys = window.config.hotkeys[commandName];
// HotkeysManager.set();
console.log(`registering hotkey: ${commandName} to binding: ${keys}`);
_hotkeysManager.registerHotkeys(commandName, keys);
});
// Force active contexts for now. These should be set in Viewer/ActiveViewer // Force active contexts for now. These should be set in Viewer/ActiveViewer
store.dispatch({ store.dispatch({
@ -61,7 +54,7 @@ store.dispatch({
item: 'VIEWER::CORNERSTONE', item: 'VIEWER::CORNERSTONE',
}); });
// ~~~~ END EPP SETUP // ~~~~ END APP SETUP
setupTools(store); setupTools(store);