diff --git a/src/UI/Components/Template/TemplateComponent.tsx b/src/UI/Components/Template/TemplateComponent.tsx index 02f567cd8..a3522ee3b 100644 --- a/src/UI/Components/Template/TemplateComponent.tsx +++ b/src/UI/Components/Template/TemplateComponent.tsx @@ -27,6 +27,7 @@ import { TemplateRecord } from '../../../DatabaseServices/Template/TemplateRecor import { SelectTempate } from '../../../DatabaseServices/Template/TemplateTest'; import { TemplateSplitType } from '../../../DatabaseServices/Template/TemplateType'; import { commandMachine, CommandWrap } from '../../../Editor/CommandMachine'; +import { CommandState } from '../../../Editor/CommandState'; import { JigUtils } from '../../../Editor/JigUtils'; import { PromptStatus } from '../../../Editor/PromptResult'; import { Filter } from '../../../Editor/SelectFilter'; @@ -1024,14 +1025,45 @@ export class TemplateManage extends React.Component { } ; }; + handleHotKey = (e: KeyboardEvent) => + { + /** keypress 不能作用与组合键 */ + + /** 没选中模板时不触发 */ + if (!this.currentTemplateInfo.id) return; + /** 正在执行命令时不触发 */ + if (CommandState.CommandIng) return; + + if (e.altKey) + { + if (e.code === 'KeyI') + { + this.handleInsert(true); + return; + } + else if (e.code === 'KeyS') + { + this.handleInsert(false); + return; + } + else if (e.code === 'KeyT') + { + this.handleReplace(); + return; + } + } + + }; componentDidMount() { ReadAutoCutConfig(TemplateManage.name, this.autoCutOption, this.option); + document.addEventListener('keyup', this.handleHotKey); } componentWillUnmount() { templateTagCommand.UploadTagList(); UploadAutoCutConfig(TemplateManage.name, this.autoCutOption, this.option); + document.removeEventListener('keyup', this.handleHotKey); } public render() { @@ -1066,7 +1098,7 @@ export class TemplateManage extends React.Component { { !this.props.R2bReplace &&