|
|
|
@ -53,6 +53,13 @@ export class CommandComponent extends React.Component<{ commandStore: CommandSto
|
|
|
|
|
ref={o => { this.inputEl = o }}
|
|
|
|
|
placeholder="(请输入命令:)"
|
|
|
|
|
onKeyDown={this.inputKeyDown}
|
|
|
|
|
onChange={(e: React.FormEvent<HTMLInputElement>) =>
|
|
|
|
|
{
|
|
|
|
|
if (e.currentTarget.value == " ")
|
|
|
|
|
{
|
|
|
|
|
e.currentTarget.value = ""
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -62,21 +69,26 @@ export class CommandComponent extends React.Component<{ commandStore: CommandSto
|
|
|
|
|
|
|
|
|
|
inputKeyDown = (e: React.KeyboardEvent<object>) =>
|
|
|
|
|
{
|
|
|
|
|
console.log(this.inputEl);
|
|
|
|
|
console.log(this.inputEl.value === "");
|
|
|
|
|
let inpValue: string = this.inputEl.value;
|
|
|
|
|
switch (e.keyCode)
|
|
|
|
|
{
|
|
|
|
|
case 13:
|
|
|
|
|
case 32:
|
|
|
|
|
this.props.commandStore.commands.push(this.inputEl.value)
|
|
|
|
|
this.inputEl.value = ""
|
|
|
|
|
if (inpValue != "")
|
|
|
|
|
{
|
|
|
|
|
this.props.commandStore.commands.push(inpValue)
|
|
|
|
|
inpValue = ""
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 27:
|
|
|
|
|
this.inputEl.value = ""
|
|
|
|
|
this.props.commandStore.commands.push("取消.")
|
|
|
|
|
if (inpValue != "")
|
|
|
|
|
{
|
|
|
|
|
inpValue = ""
|
|
|
|
|
this.props.commandStore.commands.push("取消.")
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
console.log(e.keyCode);
|
|
|
|
|
// console.log(e.keyCode);
|
|
|
|
|
}
|
|
|
|
|
}
|