mirror of https://github.com/lgc-4/DataTools3.git
30 lines
663 B
JavaScript
30 lines
663 B
JavaScript
class TextBox extends Box {
|
|
textbox;
|
|
|
|
constructor() {
|
|
super("Text Box");
|
|
|
|
let input = new Connector(Connector.INPUT);
|
|
input.addListener((data) => {
|
|
this.outputs[0].send(data);
|
|
this.textbox.value = data;
|
|
});
|
|
|
|
this.inputs.push(input);
|
|
this.outputs.push(new Connector(Connector.OUTPUT));
|
|
}
|
|
|
|
buildElement() {
|
|
if (this.element) return this.element;
|
|
super.buildElement();
|
|
|
|
this.textbox = document.createElement("textarea");
|
|
this.textbox.placeholder = "Lots of text...";
|
|
this.textbox.addEventListener("input", () => {
|
|
this.outputs[0].send(this.textbox.value);
|
|
})
|
|
this.content.appendChild(this.textbox);
|
|
|
|
return this.element;
|
|
}
|
|
} |