I'm creating a List.
Some items in the list will be a Label, some an InputText but some I would like to have both. Think a terminal window. Some lines just display text, others have a prompt with the ability to have the user enter text. Also, it would be nice for all the items to default to being at the top instead of being centered. The reason the prompt is separate from input is so the user doesn't delete the prompt text.
I was trying to make an object with both a Label and InputText in it. It won't show up.
I've created some test items for the list. Later, it will be more dynamic.
This is the relevant code:
//Items in the list
let data = [ ];
//Prompt text
let promptLabel = new Label({
text: "[prompt~]#",
labelWidth: 100,
size: 14,
font: "Arial",
color: white,
rollColor: black,
backgroundColor: black,
});
//user input text
let inputText = new TextInput({
text: "Type here",
size: 14,
font: "Arial",
color: white,
backgroundColor: black,
borderWidth: 0,
width: 598,
cursorColor: white,
});
//Display only text, full width
new Label({
text: "Some text reply from server to display.",
labelWidth: 700,
size: 14,
font: "Arial",
color: white,
backgroundColor: black,
rollColor: black,
});
//List item renderers
//Contains the prompt label and a place for the user to input text
let inputRenderer = { promptLabel, inputText };
//Adding some Label lines for testing
for (var d=0;d<8;d++){
var txt = new Label({
text: d+" Some text to display.",
labelWidth: 700,
size: 14,
font: "Arial",
color: white,
backgroundColor: black,
rollColor: black,
});
data.push(txt)
}
//Adding an object with both a label and an input text field
data.push(inputRenderer)
//The list
const displayList = new List({
list: data,
viewNum: 10,
align: LEFT,
scrollBarActive: true,
indent: 0,
labelIndentH: 0,
backgroundColor: black,
rollBackgroundColor: black,
selectedBackgroundColor: black,
backdropColor: black,
selectedRollColor: black,
rollColor: black,
currentSelected:false,
padding: 1,
noScale: true,
index: 0,
width: 750,
height: 500,
}).loc(5, 100);
displayList.scrollBar.size = 20;
S.update();