From cd5d7fb0be3e5e25119c18532846a016c20f08b3 Mon Sep 17 00:00:00 2001 From: hamed musallam Date: Tue, 30 Jun 2026 11:38:02 +0200 Subject: [PATCH] refactor: update zoom-out tooltip based on primary key state --- src/component/context/KeyModifierContext.tsx | 5 +++++ src/component/toolbar/nmr_toolbar.tsx | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/component/context/KeyModifierContext.tsx b/src/component/context/KeyModifierContext.tsx index 3d7c73ac8..1803c6f61 100644 --- a/src/component/context/KeyModifierContext.tsx +++ b/src/component/context/KeyModifierContext.tsx @@ -74,6 +74,11 @@ function getModifiersKey(event: EventModifierKeys) { return toModifiersKey(keyModifiers); } +export function useIsPrimaryKeyActivated() { + const { primaryKeyIdentifier } = useMapKeyModifiers(); + return primaryKeyIdentifier === 'shift[false]_ctrl[false]_alt[false]'; +} + export function useMapKeyModifiers() { const { current: { diff --git a/src/component/toolbar/nmr_toolbar.tsx b/src/component/toolbar/nmr_toolbar.tsx index da56c4b9c..1d3581823 100644 --- a/src/component/toolbar/nmr_toolbar.tsx +++ b/src/component/toolbar/nmr_toolbar.tsx @@ -30,6 +30,7 @@ import { Toolbar, TooltipHelpContent } from 'react-science/ui'; import { isQuadrants2DSpectrum } from '../../data/data2d/Spectrum2D/isSpectrum2D.js'; import { useChartData } from '../context/ChartContext.js'; import { useDispatch } from '../context/DispatchContext.js'; +import { useIsPrimaryKeyActivated } from '../context/KeyModifierContext.tsx'; import { useLoader } from '../context/LoaderContext.js'; import { usePreferences } from '../context/PreferencesContext.js'; import type { ToolbarPopoverMenuItem } from '../elements/ToolbarPopoverItem.js'; @@ -99,6 +100,7 @@ export default function NMRToolbar() { const isButtonVisible = useCheckToolsVisibility(); const dispatch = useDispatch(); const spectrum = useSpectrum(); + const isPrimaryKeyActivated = useIsPrimaryKeyActivated(); const { isRealSpectrumShown, @@ -234,8 +236,7 @@ export default function NMRToolbar() { { title: 'Horizontal', shortcuts: ['f'] }, { title: 'Horizontal and Vertical', shortcuts: ['f', 'f'] }, ], - description: - 'Zoom out by double-clicking the left mouse button, and fully zoom out horizontally by pressing the key "f". Alternatively, press the key "ff" to fit the spectra horizontally and vertically.', + description: `Zoom out by ${isPrimaryKeyActivated ? 'Shift + ' : ''}double-clicking the left mouse button, and fully zoom out horizontally by pressing the key "f". Alternatively, press the key "ff" to fit the spectra horizontally and vertically.`, link: 'https://docs.nmrium.org/help/zoom-and-scale', }, onClick: handleFullZoomOut,