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'; import InpaintingSplitLayoutControl from './InpaintingControls/InpaintingSplitLayoutControl';
const InpaintingControls = () => { 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 ( return (
<div className="inpainting-settings"> <div className="inpainting-settings">
<div className="inpainting-buttons-group"> <div className="inpainting-buttons-group">

View File

@ -1,6 +1,7 @@
import { createSelector } from '@reduxjs/toolkit'; import { createSelector } from '@reduxjs/toolkit';
import _ from 'lodash'; import _ from 'lodash';
import { useEffect, useRef } from 'react'; import { useEffect, useRef } from 'react';
import { useHotkeys } from 'react-hotkeys-hook';
import { import {
RootState, RootState,
useAppDispatch, useAppDispatch,
@ -12,6 +13,7 @@ import {
InpaintingState, InpaintingState,
setIsSpacebarHeld, setIsSpacebarHeld,
setShouldLockBoundingBox, setShouldLockBoundingBox,
toggleShouldLockBoundingBox,
toggleTool, toggleTool,
} from '../inpaintingSlice'; } from '../inpaintingSlice';
@ -56,6 +58,20 @@ const KeyboardEventManager = () => {
const wasLastEventOverCanvas = useRef<boolean>(false); const wasLastEventOverCanvas = useRef<boolean>(false);
const lastEvent = useRef<KeyboardEvent | null>(null); 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(() => { useEffect(() => {
const listener = (e: KeyboardEvent) => { const listener = (e: KeyboardEvent) => {
if ( if (