清理代码

pull/2/head
ChenX 7 years ago
parent 16d7e98701
commit 51684bb7da

@ -2,7 +2,6 @@ import { KeyBoard } from "../../Common/KeyEnum";
import { IsChar, IsNumble } from "../../Common/Utils";
import { DynamicInputManage } from "./DynamicInputManage";
/**
*
* ,inputEl
@ -19,31 +18,7 @@ export class DynamicInput
this.inputEl = document.createElement('input');
this.inputEl.style.position = "fixed";//默认为绝对定位 当加入到指定的容器中时,可以设置其定位方式.
this.inputEl.oninput = () => { this.OnInput() };
this.inputEl.onkeydown = (e) =>
{
if (IsChar(e.keyCode) || IsNumble(e.keyCode))
{
e.stopPropagation();
}
else
{
switch (e.keyCode)
{
case KeyBoard.Enter:
DynamicInputManage.GetManage().HandleInputEvent("");
e.stopPropagation();
break;
case KeyBoard.CommaChrome://TODO:逗号时切换..失败.
e.preventDefault();
break;
case KeyBoard.Backspace:
break;
default://阻止其他的事件
e.preventDefault();
break;
}
}
};
this.inputEl.onkeydown = (e) => this.OnInputKeyDown(e);
container.appendChild(this.inputEl);
this.Blur();
}
@ -61,6 +36,28 @@ export class DynamicInput
{
this.UpdateWidth();
}
OnInputKeyDown(e: KeyboardEvent)
{
if (IsChar(e.keyCode) || IsNumble(e.keyCode))
{
e.stopPropagation();
}
else
{
switch (e.keyCode)
{
case KeyBoard.Enter:
DynamicInputManage.GetManage().HandleInputEvent("");
e.stopPropagation();
break;
case KeyBoard.Backspace:
break;
default://阻止其他的事件
e.preventDefault();
break;
}
}
}
//激活焦点
public Focus()
{

@ -73,9 +73,7 @@ export class DynamicInputManage
{
case KeyBoard.Tab:
e.preventDefault();
this.inputCollection[this.focusIndex].Blur();
this.focusIndex = FixIndex(this.focusIndex + 1, this.inputCollection);
this.inputCollection[this.focusIndex].Focus();
this.NextFocus();
break;
case KeyBoard.Enter:
case KeyBoard.Space:
@ -86,6 +84,13 @@ export class DynamicInputManage
break;
}
}
public NextFocus()
{
this.inputCollection[this.focusIndex].Blur();
this.focusIndex = FixIndex(this.focusIndex + 1, this.inputCollection);
this.inputCollection[this.focusIndex].Focus();
}
public SendInput()
{

Loading…
Cancel
Save