Change text of widget during runtime

Hi,

I have this digital clock in my game, and i want to change the digits when pressing buttons. The firing of the event when pressing the button works. So the function to change the digit gets called. It even changes the digits, but somehow it does’t show in the game. The digits are a widget of the widget class “W_ClockDigits” inside my digital clock blueprint. I change the text of the digits right inside the widget class.

You can see the numbers increasing in the top left corner, but it wont change the digits on the screen.

Is the widget on the screen a different instance of the widget class than the one I’m changing? Is it maybe because i did’t add the widget to the viewport? I don’t know what i could have done wrong. Please help.


This is the graph of the widget class

On the off chance that this might be helpful, I can quote what ChatGPT just yesterday told me:

For game elements that use these widgets (e.g., characters, items, UI elements), you need a system to notify them that the contents have been updated. Here are a few strategies:

  • Observer Pattern: Implement an observer pattern where game elements register themselves to listen for widget updates. When a widget update occurs, notify these observers to refresh their visuals.
  • Direct Reference Update: If the game elements directly reference the manager or component storing the widgets, they can check for updates (e.g., via a tick function) and refresh their widgets accordingly.
  • Event System: Use Unreal Engine’s event system to broadcast a “Widget Updated” event. Game elements that listen for this event can then update their widgets when it’s triggered.

Ok this might be it, I’ll try. Thanks :slight_smile:


I fire an event dispatcher when changing the text now.


I bind the event to the digital clock blueprint, and update the widget. But still, it doesnt work :frowning: