How do I detect line breaks

Get help using Construct 2

Post » Tue Aug 05, 2014 12:27 pm

Hi!

Is it possible to detect how many line breaks (also called text wraps/newlines) the text inside a text object has?

Another solution to my problem might be to automatically set the height of a text object based on the lines it's will contain. Is that possible?

I need this in order to figure out if the text I'm dynamically inserting to a text object has one or two lines, so that I can create a new text object below it at the correct y-distance.

Besides the wording I used in the title, I also tried searching with the following search words: "detect line wrap", "number of line wraps".
B
9
S
1
Posts: 97
Reputation: 715

Post » Tue Aug 05, 2014 4:24 pm

Try this
RegexMatchCount(TextBox.Text,newline,"g")
B
15
S
3
G
3
Posts: 93
Reputation: 1,466

Post » Tue Aug 05, 2014 8:41 pm

Good idea, thanks I will try this!
B
9
S
1
Posts: 97
Reputation: 715

Post » Tue Aug 05, 2014 9:40 pm

Or if you just want to place another text object below your first object
Try this:

TextObject2: Set Position to
X: Text.X
Y: Text.Y + Text.TextHeight + "Your line height value"
B
15
S
3
G
3
Posts: 93
Reputation: 1,466


Return to How do I....?

Who is online

Users browsing this forum: khelaghor and 33 guests