mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): ignore keyboard shortcuts in input/textarea elements
This commit is contained in:
parent
d8515b6efc
commit
ddfc8785b4
@ -501,11 +501,15 @@ export const setStageEventHandlers = ({
|
|||||||
if (e.repeat) {
|
if (e.repeat) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Cancel shape drawing on escape
|
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
|
// Cancel shape drawing on escape
|
||||||
setIsDrawing(false);
|
setIsDrawing(false);
|
||||||
setLastMouseDownPos(null);
|
setLastMouseDownPos(null);
|
||||||
} else if (e.key === ' ') {
|
} else if (e.key === ' ') {
|
||||||
|
// Select the view tool on space key down
|
||||||
setToolBuffer(getToolState().selected);
|
setToolBuffer(getToolState().selected);
|
||||||
setTool('view');
|
setTool('view');
|
||||||
} else if (e.key === 'r') {
|
} else if (e.key === 'r') {
|
||||||
@ -527,11 +531,14 @@ export const setStageEventHandlers = ({
|
|||||||
window.addEventListener('keydown', onKeyDown);
|
window.addEventListener('keydown', onKeyDown);
|
||||||
|
|
||||||
const onKeyUp = (e: KeyboardEvent) => {
|
const onKeyUp = (e: KeyboardEvent) => {
|
||||||
// Cancel shape drawing on escape
|
|
||||||
if (e.repeat) {
|
if (e.repeat) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (e.key === ' ') {
|
if (e.key === ' ') {
|
||||||
|
// Revert the tool to the previous tool on space key up
|
||||||
const toolBuffer = getToolState().selectedBuffer;
|
const toolBuffer = getToolState().selectedBuffer;
|
||||||
setTool(toolBuffer ?? 'move');
|
setTool(toolBuffer ?? 'move');
|
||||||
setToolBuffer(null);
|
setToolBuffer(null);
|
||||||
|
Loading…
Reference in New Issue
Block a user