Skip to content

Commit

Permalink
fix(decodeImage):Fix htj2k image decode and mouse key modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
wayfarer3130 committed Nov 25, 2022
1 parent 0256dc1 commit d8752c5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
decodeImageFrame,
getImageFrame,
external,
} from 'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneWADOImageLoader.min';
} from 'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneWADOImageLoader.min.js';

function getImageRetrievalPool() {
return external.cornerstone.imageRetrievalPoolManager;
Expand Down
7 changes: 7 additions & 0 deletions packages/tools/src/enums/ToolBindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ enum KeyboardBindings {
Shift = 16,
Ctrl = 17,
Alt = 18,
Meta = 91,
ShiftCtrl = 1617,
ShiftAlt = 1618,
ShiftMeta = 1691,
CtrlAlt = 1718,
CtrlMeta = 1791,
AltMeta = 1891,
}

export { MouseBindings, KeyboardBindings };
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ToolGroupManager } from '../../store';
import { MouseBindings, ToolModes } from '../../enums';
import { keyEventListener } from '../../eventListeners';
import { EventTypes } from '../../types';
import getMouseModifier from './getMouseModifier';

const { Active } = ToolModes;

Expand All @@ -22,7 +23,9 @@ export default function getActiveToolForMouseEvent(
const mouseEvent = evt.detail.event;

// If any keyboard modifier key is also pressed
const modifierKey = keyEventListener.getModifierKey();
// Use the actual key if set, otherwise get the key from the mouse event.
const modifierKey =
keyEventListener.getModifierKey() || getMouseModifier(mouseEvent);

const toolGroup = ToolGroupManager.getToolGroupForViewport(
viewportId,
Expand Down
18 changes: 18 additions & 0 deletions packages/tools/src/eventDispatchers/shared/getMouseModifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { KeyboardBindings as kb } from '../../enums';

/**
* Gets the mouse modifier key from a mouse event.
* Supports Shift, Ctrl, Alt, in singly and in combinations of 2
* Supports Meta singly.
*/
const getMouseModifierKey = (evt) =>
(evt.shiftKey &&
((evt.ctrlKey && kb.ShiftCtrl) ||
(evt.altKey && kb.ShiftAlt) ||
kb.Shift)) ||
(evt.ctrlKey && ((evt.altKey && kb.CtrlAlt) || kb.Ctrl)) ||
(evt.altKey && kb.Alt) ||
(evt.metaKey && kb.Meta) ||
undefined;

export default getMouseModifierKey;

0 comments on commit d8752c5

Please sign in to comment.