Wrap text preemptively

Okay i came up with a solution:

I created a Widget with following setup:

  • The multi line text box
  • The text to print as string array one word per element
  • width of the textbox in chars before the linebreak (you have to try it out to find the correct number, in my textbox the correct value was 35
  • position to print the next word in the current text box line (to test for line wrap)
  • newline char (can be created by pressing shift+enter in the string field)
  • space character

99435-variables.jpg

This are the helper functions I use:

And here is the event graph in the widget:

To summarize my algorithm I test every word to print if it would create the unwanted line wrap in the text box. If it would be the case I print a newline char before it. Then I print the word char by char with a delay through the modified foreach loop in a similar way you do.

I hope this helps. If you cant understand my blueprints just feel free to ask. Greetings

1 Like