Fixing hotkeys issues
This commit is contained in:
parent
f4e76d9544
commit
68f7626515
@ -34,6 +34,7 @@ export class HotkeysContext {
|
|||||||
const bind = hotkey => $(document).bind(bindingKey, hotkey, event => {
|
const bind = hotkey => $(document).bind(bindingKey, hotkey, event => {
|
||||||
if (!this.enabled.get()) return;
|
if (!this.enabled.get()) return;
|
||||||
OHIF.commands.run(command);
|
OHIF.commands.run(command);
|
||||||
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (hotkey instanceof Array) {
|
if (hotkey instanceof Array) {
|
||||||
|
|||||||
@ -1,25 +1,27 @@
|
|||||||
import { Template } from 'meteor/templating';
|
import { Template } from 'meteor/templating';
|
||||||
|
import { ReactiveVar } from 'meteor/reactive-var';
|
||||||
import { $ } from 'meteor/jquery';
|
import { $ } from 'meteor/jquery';
|
||||||
import { _ } from 'meteor/underscore';
|
import { _ } from 'meteor/underscore';
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
Template.hotkeysForm.onCreated(() => {
|
Template.hotkeysForm.onCreated(() => {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
|
const { contextName } = instance.data;
|
||||||
|
|
||||||
instance.api = {
|
instance.api = {
|
||||||
save() {
|
save() {
|
||||||
const { contextName } = instance.data;
|
|
||||||
const form = instance.$('form').first().data('component');
|
const form = instance.$('form').first().data('component');
|
||||||
const definitions = form.value();
|
const definitions = form.value();
|
||||||
const promise = OHIF.hotkeys.store(contextName, definitions);
|
const promise = OHIF.hotkeys.store(contextName, definitions);
|
||||||
promise.then(() => OHIF.ui.notifications.success({
|
promise.then(() => {
|
||||||
text: 'The keyboard shortcut preferences were successfully saved.'
|
const successMessage = 'The keyboard shortcut preferences were successfully saved.';
|
||||||
}));
|
OHIF.ui.notifications.success({ text: successMessage });
|
||||||
|
OHIF.hotkeys.load(contextName).then(defs => instance.hotkeysDefinitions.set(defs));
|
||||||
|
});
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
resetDefaults() {
|
resetDefaults() {
|
||||||
const { contextName } = instance.data;
|
|
||||||
const dialogOptions = {
|
const dialogOptions = {
|
||||||
class: 'themed',
|
class: 'themed',
|
||||||
title: 'Reset Keyboard Shortcuts',
|
title: 'Reset Keyboard Shortcuts',
|
||||||
@ -93,9 +95,13 @@ Template.hotkeysForm.onCreated(() => {
|
|||||||
'': [],
|
'': [],
|
||||||
ALT: ['SPACE'],
|
ALT: ['SPACE'],
|
||||||
SHIFT: [],
|
SHIFT: [],
|
||||||
CTRL: ['F4', 'F5', 'F11', 'W', 'R', 'T', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'PAGEDOWN', 'PAGEUP'],
|
CTRL: ['F4', 'F5', 'F11', 'W', 'R', 'T', 'O', 'P', 'A', 'D', 'F', 'G', 'H', 'J', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'PAGEDOWN', 'PAGEUP'],
|
||||||
'CTRL+SHIFT': ['Q', 'W', 'R', 'T', 'P', 'A', 'H', 'V', 'B', 'N']
|
'CTRL+SHIFT': ['Q', 'W', 'R', 'T', 'P', 'A', 'H', 'V', 'B', 'N']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hotkeysContext = OHIF.hotkeys.getContext(contextName) || {};
|
||||||
|
instance.hotkeysDefinitions = new ReactiveVar(hotkeysContext.definitions);
|
||||||
|
OHIF.hotkeys.load(contextName).then(defs => instance.hotkeysDefinitions.set(defs));
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.hotkeysForm.events({
|
Template.hotkeysForm.events({
|
||||||
@ -201,11 +207,10 @@ Template.hotkeysForm.helpers({
|
|||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
const { contextName } = instance.data;
|
const { contextName } = instance.data;
|
||||||
|
|
||||||
const hotkeysContext = OHIF.hotkeys.getContext(contextName);
|
const hotkeyDefinitions = instance.hotkeysDefinitions.get();
|
||||||
const commandsContext = OHIF.commands.getContext(contextName);
|
const commandsContext = OHIF.commands.getContext(contextName);
|
||||||
if (!hotkeysContext || !commandsContext) return {};
|
if (!hotkeyDefinitions || !commandsContext) return {};
|
||||||
|
|
||||||
const hotkeyDefinitions = hotkeysContext.definitions;
|
|
||||||
const commands = Object.keys(OHIF.hotkeys.defaults[contextName] || {});
|
const commands = Object.keys(OHIF.hotkeys.defaults[contextName] || {});
|
||||||
const list = [];
|
const list = [];
|
||||||
commands.forEach(commandName => {
|
commands.forEach(commandName => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user