|
|
|
@ -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()
|
|
|
|
|
{
|
|
|
|
|