|
|
|
@ -14,9 +14,14 @@ export class DynamicInput
|
|
|
|
|
//创建的新输入框
|
|
|
|
|
inputEl: HTMLInputElement;
|
|
|
|
|
lockEl: HTMLElement;
|
|
|
|
|
//包装自身的容器.
|
|
|
|
|
container: HTMLElement;
|
|
|
|
|
UpdateWidth: Function;
|
|
|
|
|
constructor(container: HTMLElement)
|
|
|
|
|
{
|
|
|
|
|
this.container = document.createElement("div");
|
|
|
|
|
this.container.style.display = "inline-block";
|
|
|
|
|
|
|
|
|
|
this.lockEl = document.createElement("span");
|
|
|
|
|
this.lockEl.className = "bp3-icon-standard bp3-icon-lock";
|
|
|
|
|
this.lockEl.style.border = "3px solid #999";
|
|
|
|
@ -24,19 +29,17 @@ export class DynamicInput
|
|
|
|
|
this.lockEl.style.lineHeight = "inherit";
|
|
|
|
|
this.lockEl.style.height = "25px";
|
|
|
|
|
this.lockEl.style.display = "none";
|
|
|
|
|
container.appendChild(this.lockEl);
|
|
|
|
|
this.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.addEventListener("change", () => { this.Lock = true; });
|
|
|
|
|
this.inputEl.style.border = "3px solid transparent";
|
|
|
|
|
container.appendChild(this.inputEl);
|
|
|
|
|
this.container.appendChild(this.inputEl);
|
|
|
|
|
container.appendChild(this.container);
|
|
|
|
|
this.UpdateWidth = AutoReSize(this.inputEl).updateWidth;
|
|
|
|
|
this.Blur();
|
|
|
|
|
}
|
|
|
|
@ -115,6 +118,10 @@ export class DynamicInput
|
|
|
|
|
this.inputEl.style.backgroundColor = '#999';
|
|
|
|
|
DynamicInputManage.GetManage().IsInputing = false;
|
|
|
|
|
|
|
|
|
|
//当用户输入一样的数值时,不会触发Change事件,如果没触发,那么就没有hasLock.
|
|
|
|
|
if (this.inputEl.selectionEnd - this.inputEl.selectionStart === 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (this.m_HasLock) this.m_HasLock = false;
|
|
|
|
|
else this.Lock = false;
|
|
|
|
|
}
|
|
|
|
@ -122,17 +129,17 @@ export class DynamicInput
|
|
|
|
|
SetPosition(x, y)
|
|
|
|
|
{
|
|
|
|
|
if (DynamicInputManage.GetManage().IsInputing) return;
|
|
|
|
|
this.inputEl.style.left = x + "px";
|
|
|
|
|
this.inputEl.style.top = y + "px";
|
|
|
|
|
this.container.style.left = `${x}px`;
|
|
|
|
|
this.container.style.top = `${y}px`;
|
|
|
|
|
}
|
|
|
|
|
//设置对象的定位方式 true为绝对定位,false 时为相对定位
|
|
|
|
|
set Fixed(v: boolean)
|
|
|
|
|
{
|
|
|
|
|
this.inputEl.style.position = v ? "fixed" : "";
|
|
|
|
|
this.container.style.position = v ? "fixed" : "";
|
|
|
|
|
}
|
|
|
|
|
//销毁.
|
|
|
|
|
Destroy()
|
|
|
|
|
{
|
|
|
|
|
this.inputEl.remove();
|
|
|
|
|
this.container.remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|