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(() => {
|
useLayoutEffect(() => {
|
||||||
log.trace('Adding stage listeners');
|
log.trace('Adding stage listeners');
|
||||||
if (asPreview) {
|
if (asPreview || !container) {
|
||||||
return;
|
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({
|
const cleanup = setStageEventHandlers({
|
||||||
stage,
|
stage,
|
||||||
$tool,
|
$tool,
|
||||||
@ -186,8 +197,18 @@ const useStageRenderer = (
|
|||||||
return () => {
|
return () => {
|
||||||
log.trace('Removing stage listeners');
|
log.trace('Removing stage listeners');
|
||||||
cleanup();
|
cleanup();
|
||||||
|
container.removeEventListener('keydown', cancelShape);
|
||||||
};
|
};
|
||||||
}, [asPreview, onBrushLineAdded, onBrushSizeChanged, onEraserLineAdded, onPointAddedToLine, onRectShapeAdded, stage]);
|
}, [
|
||||||
|
asPreview,
|
||||||
|
onBrushLineAdded,
|
||||||
|
onBrushSizeChanged,
|
||||||
|
onEraserLineAdded,
|
||||||
|
onPointAddedToLine,
|
||||||
|
onRectShapeAdded,
|
||||||
|
stage,
|
||||||
|
container,
|
||||||
|
]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
log.trace('Updating stage dimensions');
|
log.trace('Updating stage dimensions');
|
||||||
|
Loading…
Reference in New Issue
Block a user