Textbox.width = Text.Width deletes string

Bugs will be moved here once resolved.

Post » Sat Dec 21, 2013 1:47 am

Link to .capx file (required!):

Steps to reproduce:
1. Create a textbox with whitespace at the end.
e.g: "I dislike trying to fix this                               "
2. Use trim to delete whitespace.. set width of the textbox to Text.TextWidth.
3. Pin an image to the center of the textbox.

Observed result:
Using trim may delete the whitespace, but it will not resize the box. When setting the box to "Text.TextWidth," frequently latter parts of the string are deleted. For example, "I dislike trying to fix this" can become "I "

Expected result:
I expected the Textbox to resize to contain ALL of the text, not just the text before the first " "

Browsers affected:
Chrome: yes

Firefox: iframe did not load correctly
"[20:37:45.634] Error: WebGL: A texture is going to be rendered as if it were black, as per the OpenGL ES 2.0.24 spec section 3.8.2, because it is a 2D texture and its width or height is equal to zero. @ http://www.progressfestival.com/BandNameGame/c2runtime.js:38"

Internet Explorer: yes

Operating system & service pack:
Windows 7

Construct 2 version:

I apologize in advanced if this has ever been addressed in the C2 forums or I am ignorantly posting something in the bugs section that does not belong here. If you would like to see an example in action, please visit www.progressfestival.com/test.php

^^you will see sections and portions of artist names, from an AJAX request to


which has all of the artist correctly listed, separated by commas.

One final thing: The AJAX request works perfectly if "Textbox.setWidth=Text.Width" is disabled. Almost every artist name does not load correctly otherwise.
Posts: 47
Reputation: 1,822

Post » Mon Dec 30, 2013 5:59 pm

The .capx you provided does not appear to match the reproduction steps. It does not use the TextWidth expression at all.
Scirra Founder
Posts: 24,244
Reputation: 192,038

Post » Tue Oct 11, 2016 2:54 am

Message: Drca can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I am having a similar issue now. TextWidth returns 0 and I would like to resize the Box containing the text so that it fits the given text perfect.

I tried the len(TextTest.Text) *12 method but I always have spare space or it cuts the word in some cases.

Here is my .capx file.

Any suggestions @Ashley ?

Thank you!
Posts: 7
Reputation: 314

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest