Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.10
more ▼

asked Dec 17 '15 at 05:53 PM in Blueprint Scripting

avatar image

11 4 6 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first


The first thing I did was to create a Widget Blueprint, and add a Text Block and two Buttons to the canvas panel.

alt text

After this, I selected the Text Block, and created a binding for it.

alt text

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.

alt text

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.

alt text

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.

alt text

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,

Sean Flint

canvaspanel.png (18.9 kB)
textbinding.png (82.7 kB)
onclicked.png (82.6 kB)
addtoviewport.png (71.3 kB)
more ▼

answered Dec 17 '15 at 08:28 PM

avatar image

Sean L ♦♦ STAFF
43.5k 485 152 442

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question