UMG Button widget, how to change its text without blueprint

Hey there,

I’ve posted this on the answerhub, but it only got 1 view after a day so I thought I’d ask here.

I have a button widget so that it has a mouse enter/leave event. I have another interface widget that has several buttons and I’d like to access the text of the button from the designer. Is that possible?

This is my button. (0 alpha background, text as child)

This is my other widget which has a few of the button widgets. I want to access the button text of the button-widget from this widget. Is that possible? Right now I’m changing it with the contruct event, but that can’t be the only way because that’s only visible after compiling & pressing play.

ehm… bind it to a variable?

click your text widget->inside details->click on bind->Create Binding->A binding function appears->

->create an FText variable->give it a default text(optional)->drag it into the function and connect the variable with the return pin

so now you can alter the text when you modify the FText variable.

OR make your TextWidget a “Variable” and access it as an object and then call “Set Text”.

Hey there.

Yes. But as far as I know (and tested), that only works if you press play, because otherwise the binding isn’t being called.

What I wanted is to change the text in the designer of my other widget so that it also updates in the designer. I know that I have access to my public variables there, but they don’t update the text without pressing play. I hope this explains it or maybe I’m doing something wrong (or maybe it’s not possible the way I mean to do it)

1 Like

There’s no way to run designer code right now, that includes bindings. This is an intentional choice as it would have side effects. Any binding sans a direct property property could corrupt the pristine version you set at design time. I’ve considered allowing the direct bindings to work, but as far as the widget code goes, it doesn’t know the difference when we init the widget between a binding that’s accessing a property directly through the special native direct binders v.s. some arbitrary blueprint or native function, running arbitrary game code. Also only the simple case is solved by this, most people would need to init a bogus mock object containing real data for their bindings to work. So just fixing direct bindings v.s. function bindings isn’t really worth pursuing I think.

I’ve got a few ideas for the future, this issue has been brought up internally as well, so we’ll eventually do something about it, because it does suck with a complex enough layering of widgets. My current thinking is that there needs to be a another tab (Sandbox Mode). That inits the widget for real in a sandbox world like Blueprints do when you click Simulate. Might even have a special function on widgets that gets called when they are created in a sandbox world, to allow a UI author to initialize mock objects, data, whatever. There’s complexity there as well, but it’s a lot more a complete solution.

Simplest work around now is have UI testing world you can play in to quickly test out these things.

Hey Nick, thanks for answering.

It really isn’t that much of a problem, but I thought maybe it would be possible somehow. It’s true it would make things easier to instantly see these things, but well, it just takes a little bit more time to test things.

A Simulate-like button would be really good so people can test the widgets instantly without having to modify or create new blueprint nodes to load the widget. (Or at least that’s what I’m doing, maybe it’s easier)

Cheers!

I got it working back in 4.5.1 by allowing bindings whose function name starts with “__” to pass in design time (which is how property bindings worked back then), but that no longer works now that I updated to 4.9, so I lost the WYSIWYG I had going for my reusable UMG components. I’m looking into ways to get that working again.

There is definitely value in having at least direct property bindings working. For example, I have a reusable “button” UMG widget that has simple properties for controlling the label, icon, color and other parameters, all controlled by direct bindings that have zero dependencies on game objects. Without design-time bindings, all my buttons are the same color and textless until I press play and navigate to their respective screens, unless I go into C++ and create my own compound widgets.

Actors are allowed to execute code at design time (with the appropriate restrictions) through the Constructor graph, Widgets should have a similar functionality. Maybe a checkbox to flag specific bindings as “editor safe” which enforces the same restrictions as constructor scripts could allow the flexibility without the need for a whole sandbox.

Reviving old thread…2019. Available yet? (Running 4.21.1, not public, if so…)

I know this post is a bit dated but I needed to do the same thing tonight and wanted to share what I did for anyone else that stumbles across this page when searching for a solution. In my case I didn’t need to use bindings as I just wanted to initialise my widget with some values that won’t change over time so this worked out just fine.

  1. Create your reusable / child widget, in this example I have a widget with two child text widgets.

  1. Add variables to your reusable / child widget, I like to categorise these as Props. Here I’ve added two Text variables, one for name and the other for description. Make sure you mark these as instance editable (The yellow eye icon).

steptwo.png

  1. Use the PreConstruct event in your reusable / child widget event graph to setup your widget based on the values provided by the given Props. This is fine for widgets that don’t need bindings (one off setup such as button labels, image assets etc…)

  1. Add your reusable / child widget to any other widget and override the exposed Props, your child widgets PreConstruct event will fire whenever you change the values of these props and you will see the updates within the designer/editor.

I hope this helps anyone else that lands on this post from google.

6 Likes

Very simple. Create the button, then create a “Text” (not a TextBox) and Drag it on top of the button. It will adjust itself accordingly. Yeah, UE doesn’t have a built-in label for the buttons, which is a bit off.

Thank you so much. I was looking exactly for something this simple and straightforward!

you have to add a f@#king text inside it

I made a whole hud a couple of years ago, I did not remember how retarded this was