Hi, I would like to change the editable text widget (UEditableText) style with cpp during runtime.
The scenario is that the players can choose different configure sections then input their configuration through editable text widget; the text’s color shall change according to the player’s choice to remind them which section they are currently in.
Hi, thanks for your reply. I tried RebuildWidget. The problem in my case is that Editabletext itself is not a UUserWidget but only a UWidget, so I can only call RebuildWidget at the parent widget class. Thus, it is wasteful as I need to rebuild the how widget tree for only one change; and it will make the logic very complicated (if not impossible) to change the build information(which is currently in a blueprint). Is there a method to rebuild the Editabletext only?
If you look at the UEditableText class, you can see that the WidgetStyle object is only used when the RebuildWidget function is called, as shown in the previous answer.
This means that updating the WidgetStyle variable does not actually cause any changes to the Slate object.
So I haven’t found a way to update the Style of the UEditableText at runtime as I want without changing the UEditableText class.
In my case, I only needed to change the font information out of the entire style, so my solution was to borrow the way a UTextBlock with a similar structure changes the font and add a custom class that inherits from UEditableText.
Of course, since I am working in a Blueprint environment, these additional class registrations were necessary, but If in a C++ environment, you may get the internal Slate widget with TakeWidget() and do the updates directly.
Here are the additional interfaces I registered