mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): cancel shape drawing on esc
This commit is contained in:
parent
b71ba63b5a
commit
3c7140cbf3
@ -161,9 +161,20 @@ const useStageRenderer = (
|
||||
|
||||
useLayoutEffect(() => {
|
||||
log.trace('Adding stage listeners');
|
||||
if (asPreview) {
|
||||
if (asPreview || !container) {
|
||||
return;
|
||||
}
|
||||
|
||||
const cancelShape = (e: KeyboardEvent) => {
|
||||
// Cancel shape drawing on escape
|
||||
if (e.key === 'Escape') {
|
||||
$isDrawing.set(false);
|
||||
$lastMouseDownPos.set(null);
|
||||
}
|
||||
};
|
||||
|
||||
container.addEventListener('keydown', cancelShape);
|
||||
|
||||
const cleanup = setStageEventHandlers({
|
||||
stage,
|
||||
$tool,
|
||||
@ -186,8 +197,18 @@ const useStageRenderer = (
|
||||
return () => {
|
||||
log.trace('Removing stage listeners');
|
||||
cleanup();
|
||||
container.removeEventListener('keydown', cancelShape);
|
||||
};
|
||||
}, [asPreview, onBrushLineAdded, onBrushSizeChanged, onEraserLineAdded, onPointAddedToLine, onRectShapeAdded, stage]);
|
||||
}, [
|
||||
asPreview,
|
||||
onBrushLineAdded,
|
||||
onBrushSizeChanged,
|
||||
onEraserLineAdded,
|
||||
onPointAddedToLine,
|
||||
onRectShapeAdded,
|
||||
stage,
|
||||
container,
|
||||
]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
log.trace('Updating stage dimensions');
|
||||
|
Loading…
Reference in New Issue
Block a user