mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Adds hotkey to reset canvas interaction state
If the canvas' interaction state (e.g. isMovingBoundingBox, isDrawing, etc) get stuck somehow, user can press Escape to reset the state.
This commit is contained in:
parent
9d34213b4c
commit
d4376ed240
@ -3,6 +3,7 @@ import _ from 'lodash';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { activeTabNameSelector } from 'features/options/store/optionsSelectors';
|
||||
import {
|
||||
resetCanvasInteractionState,
|
||||
setShouldShowBoundingBox,
|
||||
setTool,
|
||||
} from 'features/canvas/store/canvasSlice';
|
||||
@ -46,6 +47,17 @@ const useInpaintingCanvasHotkeys = () => {
|
||||
|
||||
const canvasStage = getCanvasStage();
|
||||
|
||||
useHotkeys(
|
||||
'esc',
|
||||
() => {
|
||||
dispatch(resetCanvasInteractionState());
|
||||
},
|
||||
{
|
||||
enabled: () => true,
|
||||
preventDefault: true,
|
||||
}
|
||||
);
|
||||
|
||||
useHotkeys(
|
||||
'shift+h',
|
||||
() => {
|
||||
|
@ -675,6 +675,16 @@ export const canvasSlice = createSlice({
|
||||
|
||||
state.layerState.objects = [action.payload];
|
||||
},
|
||||
resetCanvasInteractionState: (state) => {
|
||||
state.cursorPosition = null;
|
||||
state.isDrawing = false;
|
||||
state.isMouseOverBoundingBox = false;
|
||||
state.isMoveBoundingBoxKeyHeld = false;
|
||||
state.isMoveStageKeyHeld = false;
|
||||
state.isMovingBoundingBox = false;
|
||||
state.isMovingStage = false;
|
||||
state.isTransformingBoundingBox = false;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -690,6 +700,7 @@ export const {
|
||||
prevStagingAreaImage,
|
||||
redo,
|
||||
resetCanvas,
|
||||
resetCanvasInteractionState,
|
||||
resetCanvasView,
|
||||
resizeAndScaleCanvas,
|
||||
resizeCanvas,
|
||||
|
@ -192,9 +192,11 @@ export default function ImageGallery() {
|
||||
useHotkeys(
|
||||
'esc',
|
||||
() => {
|
||||
if (shouldPinGallery) return;
|
||||
dispatch(setShouldShowGallery(false));
|
||||
dispatch(setDoesCanvasNeedScaling(true));
|
||||
},
|
||||
{
|
||||
enabled: () => !shouldPinGallery,
|
||||
preventDefault: true,
|
||||
},
|
||||
[shouldPinGallery]
|
||||
);
|
||||
|
@ -72,9 +72,11 @@ const InvokeOptionsPanel = (props: Props) => {
|
||||
useHotkeys(
|
||||
'esc',
|
||||
() => {
|
||||
if (shouldPinOptionsPanel) return;
|
||||
dispatch(setShouldShowOptionsPanel(false));
|
||||
dispatch(setDoesCanvasNeedScaling(true));
|
||||
},
|
||||
{
|
||||
enabled: () => !shouldPinOptionsPanel,
|
||||
preventDefault: true,
|
||||
},
|
||||
[shouldPinOptionsPanel]
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user