Adding childs to UIElement

I need to programatically add several children to an existing UIElement, through this code:

for (i=0;i<numChoices;i++){
  Text@ t =Text();
  t.text = choices[i];

But the children arent displayed. I tried creating an array of Text@, but that didnt worked neither.

Try like this:

for (i=0;i<numChoices;i++){ Text@ t =Text(); dlgWindow.AddChild(t); t.text = choices[i]; = "Text"; }

Which is a problem, the parent layout should be updated when a child is added to it that is already styled. I did look into it at one point and it’s something to do with how it works out the minimum size.

Damn, the same problem hit me when using a listview and I forgot I have to set the style.

Ok, solved the text problem, but seems that Text doesnt handles click events. Tried to put the texts inside buttons, but I just get an empty button.

[code]for (int i = 0; i < d.answers.length; i++) {
Button@ buttons = Button();
Text@ answers = Text();
answers.text = d.answers[i]; = d.ids[i];
buttons.AddChild(answers); = “Text”;
buttons.SetMinSize(500, 22);
SubscribeToEvent(“UIMouseClick”, “HandleControlClicked”);


Whats missing now?

You need to actually enable text for input-- by default it’s disabled (if that wasn’t the case, a text in a button would receive events instead of the button, which is usually not what you want):