Creating a hotkeys context for viewer
This commit is contained in:
1 parent
5e7edd91ee
commit
2f81c0e2e7
9 files changed
+53
-91
No files matched your search
+7
-1
@@ -28,7 +28,7 @@ export class HotkeysContext {
|
||||
return OHIF.log.warn(message);
|
||||
}
|
||||
|
||||
$(document).bind(`keydown.hotkey.${this.name}`, hotkey, event => {
|
||||
const bindHotkey = hotkey => $(document).bind(`keydown.hotkey.${this.name}`, hotkey, event => {
|
||||
if (!this.enabled.get()) return;
|
||||
if (typeof disabled !== undefined) {
|
||||
if ((typeof disabled === 'function' && disabled()) || disabled) return;
|
||||
@@ -36,6 +36,12 @@ export class HotkeysContext {
|
||||
|
||||
action(event);
|
||||
});
|
||||
|
||||
if (hotkey instanceof Array) {
|
||||
hotkey.forEach(hotkey => bindHotkey(hotkey));
|
||||
} else {
|
||||
bindHotkey(hotkey);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { ReactiveVar } from 'meteor/reactive-var';
|
||||
import { HotkeysContext } from 'meteor/ohif:hotkeys/client/HotkeysContext';
|
||||
import { HotkeysContext } from 'meteor/ohif:hotkeys/client/classes/HotkeysContext';
|
||||
|
||||
export class HotkeysManager {
|
||||
constructor() {
|
||||
@@ -0,0 +1 @@
|
||||
import './lib';
|
||||
@@ -0,0 +1 @@
|
||||
import './routes';
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Router } from 'meteor/iron:router';
|
||||
import { Session } from 'meteor/session';
|
||||
import { hotkeys } from 'meteor/ohif:hotkeys';
|
||||
|
||||
Router.onBeforeAction(function() {
|
||||
const lastRoute = Session.get('lastRoute');
|
||||
const currentRoute = this.router.current().route.getName();
|
||||
if (currentRoute !== lastRoute) {
|
||||
hotkeys.switchToContext(null);
|
||||
Session.set('lastRoute', currentRoute);
|
||||
}
|
||||
|
||||
this.next();
|
||||
});
|
||||
Reference in new issue
Block a user