From d6f0092a3236cecb5d04ec46c8ad01600500831e Mon Sep 17 00:00:00 2001 From: Gas Giant Date: Fri, 24 Jan 2025 19:12:00 +0530 Subject: [PATCH] feat: delete active annotation using backspace/delete key (#4722) Co-authored-by: scouser --- extensions/cornerstone/src/commandsModule.ts | 10 ++++++++++ platform/core/src/defaults/hotkeyBindings.js | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/extensions/cornerstone/src/commandsModule.ts b/extensions/cornerstone/src/commandsModule.ts index 66d7ee6e9..469e9fcb6 100644 --- a/extensions/cornerstone/src/commandsModule.ts +++ b/extensions/cornerstone/src/commandsModule.ts @@ -13,6 +13,7 @@ import { ReferenceLinesTool, annotation, } from '@cornerstonejs/tools'; +import * as cornerstoneTools from '@cornerstonejs/tools'; import { Types as OhifTypes, utils } from '@ohif/core'; import i18n from '@ohif/i18n'; @@ -1298,6 +1299,12 @@ function commandsModule({ viewportGridService.getActiveViewportId() ); }, + deleteActiveAnnotation: () => { + const activeAnnotationsUID = cornerstoneTools.annotation.selection.getAnnotationsSelected(); + activeAnnotationsUID.forEach(activeAnnotationUID => { + measurementService.remove(activeAnnotationUID); + }); + }, }; const definitions = { @@ -1558,6 +1565,9 @@ function commandsModule({ getRenderInactiveSegmentations: { commandFn: actions.getRenderInactiveSegmentations, }, + deleteActiveAnnotation: { + commandFn: actions.deleteActiveAnnotation, + }, }; return { diff --git a/platform/core/src/defaults/hotkeyBindings.js b/platform/core/src/defaults/hotkeyBindings.js index b4c609893..34c22f52e 100644 --- a/platform/core/src/defaults/hotkeyBindings.js +++ b/platform/core/src/defaults/hotkeyBindings.js @@ -173,6 +173,10 @@ const bindings = [ label: 'W/L Preset 5', keys: ['5'], }, + { + commandName: 'deleteActiveAnnotation', + keys: ['backspace'], + }, // These don't exist, so don't try applying them.... // { // commandName: 'setWindowLevel',