How to procedurally create static text widgets and put them in a horizontal box

I’m making a spelling game for manly stroke victims but can be used for others.
I’m trying to show where the user made a mistake and set the color to red for those letters.

The only solution I can think of is to procedurally create static text widgets. Use a branch for each letter and set the color for each. With a for each loop that breaks down the string. Place them into a horizontal box.
problem is that I don’t see a way to make this happen any help would be great thank you.

create a new widget that contains only text and create a variable(string/text/name) inside that widget

bind the variable to the widgets Text

then in your for loop create that new widget and add it to your horizontal box

that should get you started in what you are trying to achieve

How to do it procedurally? like create the widget automatically, I don’t do it myself.

you expose the variable on spawn and when you create a new widget a new input pin will appear

and I dont have to do it my self?

that depends entirely how you setup your widget and what information you want to give that widget through your forloop

I suggest you run a simple test to first understand how to add widgets during runtime to your horizontal box

Thing is I don’t understand how? I dont get what your trying to say

Let’s start with creating a new widget

Remove the canvas and add text
image

Create a new string variable
image

In that variable, enable ‘Instance Editable’ and ‘Expose on spawn’
image

Close that widget and open your main widget

in your for loop create and add your new widget and input data inside the extra pins that show up

that will create your widgets dynamically to get you started…

to get the syntax you are after, you might be able to use “Rick Text Block” instead of just Text

3 Likes

Im going to try it and let you know how it goes thank you for your example!

1 Like

This is the way to go, to get you a little bit closer:

Turn the text into an array and push letter widgets into a horizontal box.

1 Like