feat: Add hotkey for Add Nodes (Shift+A)

Standard with other tools like Blender
This commit is contained in:
blessedcoolant 2023-08-22 03:31:29 +12:00
parent 01738deb23
commit 7b2079cf83
3 changed files with 34 additions and 0 deletions

View File

@ -133,6 +133,7 @@
"generalHotkeys": "General Hotkeys",
"galleryHotkeys": "Gallery Hotkeys",
"unifiedCanvasHotkeys": "Unified Canvas Hotkeys",
"nodesHotkeys": "Nodes Hotkeys",
"invoke": {
"title": "Invoke",
"desc": "Generate an image"
@ -332,6 +333,10 @@
"acceptStagingImage": {
"title": "Accept Staging Image",
"desc": "Accept Current Staging Area Image"
},
"addNodes": {
"title": "Add Nodes",
"desc": "Opens the add node menu"
}
},
"modelManager": {

View File

@ -2,6 +2,7 @@ import { useAppDispatch } from 'app/store/storeHooks';
import IAIButton from 'common/components/IAIButton';
import { addNodePopoverOpened } from 'features/nodes/store/nodesSlice';
import { memo, useCallback } from 'react';
import { useHotkeys } from 'react-hotkeys-hook';
import { Panel } from 'reactflow';
const TopLeftPanel = () => {
@ -11,6 +12,10 @@ const TopLeftPanel = () => {
dispatch(addNodePopoverOpened());
}, [dispatch]);
useHotkeys(['shift+a'], () => {
handleOpenAddNodePopover();
});
return (
<Panel position="top-left">
<IAIButton aria-label="Add Node" onClick={handleOpenAddNodePopover}>

View File

@ -286,6 +286,14 @@ export default function HotkeysModal({ children }: HotkeysModalProps) {
},
];
const nodesHotkeys = [
{
title: t('hotkeys.addNodes.title'),
desc: t('hotkeys.addNodes.desc'),
hotkey: 'Shift + A',
},
];
const renderHotkeyModalItems = (hotkeys: HotkeyList[]) => (
<Flex flexDir="column" gap={4}>
{hotkeys.map((hotkey, i) => (
@ -377,6 +385,22 @@ export default function HotkeysModal({ children }: HotkeysModalProps) {
{renderHotkeyModalItems(unifiedCanvasHotkeys)}
</AccordionPanel>
</AccordionItem>
<AccordionItem>
<AccordionButton>
<Flex
width="100%"
justifyContent="space-between"
alignItems="center"
>
<h2>{t('hotkeys.nodesHotkeys')}</h2>
<AccordionIcon />
</Flex>
</AccordionButton>
<AccordionPanel>
{renderHotkeyModalItems(nodesHotkeys)}
</AccordionPanel>
</AccordionItem>
</Flex>
</Accordion>
</ModalBody>