Dynamic Slate Problem

Hello,

I want to create a dynamic slate components that are added when i press a button. Thus, i have made this code:

        SNew(SHorizontalBox)
        + SHorizontalBox::Slot()
        .AutoWidth()
        .VAlign(VAlign_Center)
        .Padding(2,2,3,2)
        [
          SNew(STextBlock)
          .Text(FText::FromString(TEXT("Scoring Angle:     ")))
        ]
        + SHorizontalBox::Slot()
        .AutoWidth()
        .Padding(1,1,3,1)
        [
            SNew(SNumericEntryBox<int>)
            .OnValueChanged_Lambda([this](auto NewValue )
            {
                if(scoring_angle.Num()>0)
                    scoring_angle[counter] = NewValue;
            })
            .Value_Lambda([this]()
            {
                if(scoring_angle.Num()>0)
                    return scoring_angle[counter];

                return 0;
            })
        ]  
        + SHorizontalBox::Slot()
        .AutoWidth()
        .VAlign(VAlign_Center)
        .Padding(1,1,3,1)
        [
          SNew(STextBlock)
          .Text(FText::FromString(TEXT("FinalPrefab:     ")))
        ]

This, creates a Scoring Angle text with a numic value. But i dont know how to have dynamic values in the scoring_angle. I have made an array, but the values are always showing the last index and not the index that I want. Every horizontalbox that it is created, it has the same value. Example in photo:

323578-1.jpg

Good evening! Perhaps, problem is caused by Lambda, that is used. Your counter is captured and it is external for Lambda. So Lambda will use the value that this variable will have in the moment of call. Calls are executed after loop, when SNumericEntryBox checks its value. You can try to solve it with this one:

.Value_Lambda([this]() {
	auto localCounter = counter;
	if(scoring_angle.Num()>0)
		return scoring_angle[localCounter];
	return 0;
})

Hello!! I tried it but I have the same result… :frowning:

I just take a wrong one. Now you can try it - it of course Value_Lambda, not OnValueChanged_Lambda =)

This doesnt help :\ Still the same issue.

Now it should work, just another typo

you havent posted anything. Still doesnt work with the change of Value_Lamda though =)

I have changed code in prev comment.