Restores shift+q bounding box shortcut

This commit is contained in:
psychedelicious 2022-11-02 11:52:19 +11:00 committed by Lincoln Stein
parent 16c8b23b34
commit 6195579910
2 changed files with 16 additions and 23 deletions

View File

@ -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 (
<div className="inpainting-settings">
<div className="inpainting-buttons-group">

View File

@ -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<boolean>(false);
const lastEvent = useRef<KeyboardEvent | null>(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 (