DataTools3/elements/TextBox.js

30 lines
680 B
JavaScript

class TextBox extends Box {
textbox;
constructor() {
super("Text Box");
let input = new Connector(Connector.INPUT, "any");
input.addListener((data) => {
this.outputs[0].send(data);
this.textbox.value = data;
});
this.inputs.push(input);
this.outputs.push(new Connector(Connector.OUTPUT, "string"));
}
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;
}
}