How can I update the text on the text widget? Lets say I want to do so when a button is pressed on the UI. Right now I have a simple button, and I want to use the on clicked event to trigger the creation of a text widget, and I want to be able to set that text when it is created.
Bind the text to a function or a variable and update that variable to change the text.
Right next to the little box you write the text in there is a button that should say “Bind”. Just click that and set everything up. Then in your
OnClick event set the variable to the new text
In your widget containing your text, you’ll need to create a binding.
To do so, click the Bind button in the Content tab of the details panel when you have your Text selected and select Create Binding.
This will open up a GetText_0 function, which you can use to pass in whatever text you’d like. You can create a text variable, an array of text and get random messages, make literal text, etc to populate the Return Value. This is what your text will be when you spawn your widget.
Then, on clicked, you’ll create your widget and it should get the text you pass into your get text function.
After this, you can update that variable any time at runtime to update the text that is displayed on your widget.
Let me know if you have any further questions regarding this setup and I’ll be glad to help.
Have a great day
I’ve found that, but it seems oddly worded. Inside the function that I’m binding It says “get”, and it only has a single slot for returning a value. No where do I see the actual variable for that text. Then when I try and find this inside a different widget (the button widget) I cannot find it.
You’ll have to create the variable yourself and plug it into the function. Once you plug your text variable into the function, you can then edit that variable anywhere, meaning you won’t need to make any changes to the function itself, just the variable.
So I’m not seeing anything when I “create widget” node inside my button on clicked event. I would expect to see the variable "Temp Text somewhere and I could set that text, and then the “bound” function would feed this into the text variable of the text.
So far what I see happening is that I can have the Widget Layer Text spawn when I click the button, but it only displays what I put there inside the layer widget. I’m trying to access that text and change it. For instance, each time I click the button I want the text to read Layer 1, layer 2, layer 3, etc…
I posted below a screen grab showing a version with the variable “Temp Text” created in the bound function. Outside in another widget called “Noise Menu” I try to create this “layerText” widget which should have the “TempText” variable. But when I use “Create Layer Text Widget” the return value doesn’t give me access to that variable “Temp Text”.
I was forgetting to make the variable in the “variable” section, instead I was making it in the local variable section