diff --git a/frontend/src/features/tabs/Inpainting/InpaintingControls.tsx b/frontend/src/features/tabs/Inpainting/InpaintingControls.tsx index 2146b35e1a..0cba70999c 100644 --- a/frontend/src/features/tabs/Inpainting/InpaintingControls.tsx +++ b/frontend/src/features/tabs/Inpainting/InpaintingControls.tsx @@ -7,29 +7,6 @@ import InpaintingClearImageControl from './InpaintingControls/InpaintingClearIma import InpaintingSplitLayoutControl from './InpaintingControls/InpaintingSplitLayoutControl'; const InpaintingControls = () => { - // const { shouldShowMask, activeTabName } = useAppSelector( - // inpaintingControlsSelector - // ); - - // const dispatch = useAppDispatch(); - - /** - * Hotkeys - */ - - // Toggle lock bounding box - // useHotkeys( - // 'shift+q', - // (e: KeyboardEvent) => { - // e.preventDefault(); - // dispatch(toggleShouldLockBoundingBox()); - // }, - // { - // enabled: activeTabName === 'inpainting' && shouldShowMask, - // }, - // [activeTabName, shouldShowMask] - // ); - return (
diff --git a/frontend/src/features/tabs/Inpainting/components/KeyboardEventManager.tsx b/frontend/src/features/tabs/Inpainting/components/KeyboardEventManager.tsx index ab2009d51f..2e244c35f1 100644 --- a/frontend/src/features/tabs/Inpainting/components/KeyboardEventManager.tsx +++ b/frontend/src/features/tabs/Inpainting/components/KeyboardEventManager.tsx @@ -1,6 +1,7 @@ import { createSelector } from '@reduxjs/toolkit'; import _ from 'lodash'; import { useEffect, useRef } from 'react'; +import { useHotkeys } from 'react-hotkeys-hook'; import { RootState, useAppDispatch, @@ -12,6 +13,7 @@ import { InpaintingState, setIsSpacebarHeld, setShouldLockBoundingBox, + toggleShouldLockBoundingBox, toggleTool, } from '../inpaintingSlice'; @@ -56,6 +58,20 @@ const KeyboardEventManager = () => { const wasLastEventOverCanvas = useRef(false); const lastEvent = useRef(null); + // Toggle lock bounding box + useHotkeys( + 'shift+q', + (e: KeyboardEvent) => { + e.preventDefault(); + dispatch(toggleShouldLockBoundingBox()); + }, + { + enabled: activeTabName === 'inpainting' && shouldShowMask, + }, + [activeTabName, shouldShowMask] + ); + + // Manages hold-style keyboard shortcuts useEffect(() => { const listener = (e: KeyboardEvent) => { if (