Change the text of a UI header based on button press?
I'm trying to set up a situation where the text of a section in the UI changes based on a button press. For example if I push button one, the section header displays "Inventory" and if I push button 2 the section header changes to "Journal". I'd like to do this without textures if possible for accessibility reasons. Thanks!
asked Dec 17 '15 at 05:53 PM in Blueprint Scripting
The first thing I did was to create a Widget Blueprint, and add a Text Block and two Buttons to the canvas panel.
After this, I selected the Text Block, and created a binding for it.
When you created the binding, it will take you to the Get Text function. Right click and promote the return value on the return node to a variable.
Finally, go into your Event Graph, and add OnClicked events for each of the buttons you created in the first step. OnClicked, set the variable that you created in the previous step to whatever text you would like it to say after you've pressed the button.
The last step is to go into the level blueprint, create a widget based on the blueprint you've created, and then add it to the viewport.
Now, when you PIE and click on your buttons, you should see the text changing based on whatever you've set the variable to OnClicked. This is just a simple test setup, but can be easily extended to support whatever functionality you'd like to give it. I hope that helps.
Have a great day,
answered Dec 17 '15 at 08:28 PM
Sean L ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here