Text Wrap

There is no way to set dynamically text “wrap text at” variable???

I have text that I have set to wrap, but the width of the widget will be unknown and change depending on the widget it is used in, and all I can find is a way to set the value of “wrap text at” in the editor directly, I cannot find a variable or method to set this value with a reference to the Text Widget…

0, by default disables wrapping (which seems odd, you would think 0 would be to wrap text to desired width of widget).

How do I make a text widget wrap text to the width of the widget?

1 Like

I’m having the same issue, it seems ridiculous. The functionality seems to be in unreal just we don’t have access to it. All we need is for us to bind (or get and set) Wrap Text At value inside blueprint!

The issue is this:

Lets say you have a pop-up menu with a block of text. There are multiple texts you can type into and you won’t know if it’s a simple word or a paragraph…
If you wanted all these pop-ups to have the same width, then there wouldn’t be any problem.
But if you want to customize each pop-up to a size you desire… then you have no control over that variable (the width aka. “Wrap Text At” value)

NOTE: Using size boxes don’t work the way you’d expect them to in this case: a size box with a max width lower than the width allowed by the Wrap Text At will just make the pop-up background smaller but the text will carry on beyond that limit.

image

Summary:

  • You have a text box with a dynamically edited text.
  • You want the whole widget (pop-up menu) to fit to the size of the text and force the text to wrap at that width or height limit you put.

PS: to know exactly how I would love it to work:

  • just take a normal text box and place it inside a canvas panel
  • write a very long text inside
  • change the size of the text box
    Watch how the text just automatically wraps…YES THATS WHAT WE WANT haha
    image
    image

@blindminds any updates from your part? have you been able to fix this?

Why don’t you use AutoWrapText=True with WrapTextAt=0? Seems like this would cover your case.

If you want auto wrapping at some maximum pixel, put a sizebox around the text and say that the size box should be max width 600.

I have had no luck with this and eventually had to give up. By giving up, I just had to set a static width for my panel header. AND…even still, text wraps unpredictably at times where it will wrap text when it seems there should be enough to not wrap the text.

setting autowrap to true and value of 0 disables wrapping. The expected behavior should be that it autowraps at the desired width of the widget (a.k.a. the current rendered width of the widget)

@blindminds I was able to fix this with a size box. Basically, auto wrap takes into consideration the Wrap text At value but will take into consideration any override value you set also. The priority is for the Wrap text At value. But if you set Wrap text At to something like 9999 and then override Width with a size box to 500, then it will function the way you expect it to. (ALMOST…) [view images: ]

If you are updating your text in run-time, then Auto Wrap sticks to the first value to wrap at that it records!! So when you update your text, it won’t work because you need to “refresh” that value by setting Auto Wrap to false, then to true after your text has been refreshed. Take note, that in the image below, I placed Delay nodes, without them, this won’t work. Because, then, Auto Wrap will set to False then true on the same frame, thus not doing anything in fact.

To test this function:

  • Create a widget
  • add canvas panel
  • add Text (not text box)
  • Toggle Auto Wrap on (set Wrap At to 9999) [Image: 1]
  • add a long paragraph of text in the text item to test it

Start changing the width of the Text item by hand, it will work. Now:

  • Right click on the Text item (in the hierarchy)
  • Wrap with: size box [Image: 3]
  • set size to Auto
  • toggle “Override Width” and set it to lets say 500 [view image: 2]
    Now your Text Item won’t scale on the width axis more than 500. And it works :warning:
    in the editor only! :warning:

To make it work, in run-time, it depends on your setup. here’s mine [image: 4]

Careful, I’ve noticed when your setup is complex and some values are being set in the graph, sometimes the editor is reactive and other times you need to compile and sometimes even after compiling it doesn’t work. But during the game it works fine.

[Image 1]

[Image 2]

[Image 3]
image

[Image 4]

Test images:


Thanks, I will check this out and see if I can get ti to work!
I might have some other child widgets causing my setup to “malfunction” as my widget hierarchy is slightly complex to get some specific visual layout.

@blindminds I edited the message I just sent, realized I’ve made mistakes. (major mistakes ^^)

@blindminds I edited my response by adding a very important detail. I had noticed the behavior wasn’t working in run-time 100% of the times (more like 1% of the times :smiley: ) So I added a fix that would probably work for your case too.

Basically, Auto Wrap isn’t updating every frame. So you have to set it to False then to True before and after you update your new text.

Intersting, I remember having that issue where it would work in editor but not at runtime.

1 Like