|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import { KeyBoard } from "../../Common/KeyEnum";
|
|
|
|
|
import { DynamicInputManage } from "./DynamicInputManage";
|
|
|
|
|
import { AutoReSize } from "../JsPlugin/InputAutoSize";
|
|
|
|
|
import { DynamicInputManage } from "./DynamicInputManage";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
@ -13,21 +13,48 @@ export class DynamicInput
|
|
|
|
|
{
|
|
|
|
|
//创建的新输入框
|
|
|
|
|
inputEl: HTMLInputElement;
|
|
|
|
|
lockEl: HTMLElement;
|
|
|
|
|
UpdateWidth: Function;
|
|
|
|
|
constructor(container: HTMLElement)
|
|
|
|
|
{
|
|
|
|
|
this.lockEl = document.createElement("span");
|
|
|
|
|
this.lockEl.className = "bp3-icon-standard bp3-icon-lock";
|
|
|
|
|
this.lockEl.style.border = "3px solid #999";
|
|
|
|
|
this.lockEl.style.background = "#f5f8fa";
|
|
|
|
|
this.lockEl.style.lineHeight = "inherit";
|
|
|
|
|
this.lockEl.style.height = "25px";
|
|
|
|
|
this.lockEl.style.display = "none";
|
|
|
|
|
container.appendChild(this.lockEl);
|
|
|
|
|
|
|
|
|
|
this.inputEl = document.createElement('input');
|
|
|
|
|
this.inputEl.style.pointerEvents = "none";
|
|
|
|
|
this.inputEl.style.minWidth = "15px";
|
|
|
|
|
this.inputEl.addEventListener("input", () => { this.OnInput() });
|
|
|
|
|
this.inputEl.addEventListener("keydown", e => { this.OnInputKeyDown(e) });
|
|
|
|
|
this.inputEl.addEventListener("change", () =>
|
|
|
|
|
{
|
|
|
|
|
this.Lock = true;
|
|
|
|
|
});
|
|
|
|
|
this.inputEl.style.border = "3px solid transparent";
|
|
|
|
|
container.appendChild(this.inputEl);
|
|
|
|
|
this.UpdateWidth = AutoReSize(this.inputEl).updateWidth;
|
|
|
|
|
this.Blur();
|
|
|
|
|
}
|
|
|
|
|
private m_Lock = false;
|
|
|
|
|
private m_HasLock = false;
|
|
|
|
|
set Lock(lock: boolean)
|
|
|
|
|
{
|
|
|
|
|
this.m_Lock = lock;
|
|
|
|
|
this.lockEl.style.display = lock ? "inline-block" : "none";
|
|
|
|
|
if (lock) this.m_HasLock = lock;
|
|
|
|
|
}
|
|
|
|
|
get Lock()
|
|
|
|
|
{
|
|
|
|
|
return this.m_Lock;
|
|
|
|
|
}
|
|
|
|
|
set Value(value: any)
|
|
|
|
|
{
|
|
|
|
|
if (this.m_Lock) return;
|
|
|
|
|
this.inputEl.value = value;
|
|
|
|
|
this.UpdateWidth();
|
|
|
|
|
this.SetSelect();
|
|
|
|
@ -59,7 +86,14 @@ export class DynamicInput
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
DynamicInputManage.GetManage().IsInputing = true;
|
|
|
|
|
|
|
|
|
|
setTimeout(() =>
|
|
|
|
|
{
|
|
|
|
|
if (this.inputEl.selectionEnd - this.inputEl.selectionStart === 0)
|
|
|
|
|
{
|
|
|
|
|
DynamicInputManage.GetManage().IsInputing = true;
|
|
|
|
|
}
|
|
|
|
|
}, 16);
|
|
|
|
|
}
|
|
|
|
|
//激活焦点
|
|
|
|
|
public Focus()
|
|
|
|
@ -80,6 +114,9 @@ export class DynamicInput
|
|
|
|
|
this.inputEl.disabled = true;
|
|
|
|
|
this.inputEl.style.backgroundColor = '#999';
|
|
|
|
|
DynamicInputManage.GetManage().IsInputing = false;
|
|
|
|
|
|
|
|
|
|
if (this.m_HasLock) this.m_HasLock = false;
|
|
|
|
|
else this.Lock = false;
|
|
|
|
|
}
|
|
|
|
|
//设置位置
|
|
|
|
|
SetPosition(x, y)
|
|
|
|
|