Change text width after changing text value

Get help using Construct 2

Post » Fri Apr 06, 2012 4:58 pm

I have this textobject which's text is updated after pressing a button.
I'm having a problem with changing the text size if a longer sentence is inputted.

I could just make the textbox huge, but i'm trying to do this because the textobject needs to be draggable, and after changing the text, you shouldn't be able to drag the text from outside it's box.

Here's an example:

http://dl.dropbox.com/u/65731657/resizetextarea.capx
B
22
S
11
G
9
Posts: 133
Reputation: 6,572

Post » Fri Apr 06, 2012 8:06 pm

Resizing the width (capx) - height should be similar
B
14
S
6
G
5
Posts: 173
Reputation: 4,742

Post » Fri Apr 06, 2012 8:08 pm

Click on the third action and change "Width" to:
len(TextBox.Text) * 8

ha, ninja'd by Joe7 Noga2012-04-06 20:10:25
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Fri Apr 06, 2012 8:57 pm

thanks guys =)
B
22
S
11
G
9
Posts: 133
Reputation: 6,572

Post » Tue Oct 11, 2016 3:00 am

Depending on the font and size, you end up with some free space or sometimes a letter is cut out of the word. Is there a way to get a pixel perfect box around a Text Object that changes its content?

Thank you!
B
4
S
1
Posts: 7
Reputation: 314

Post » Tue Oct 11, 2016 9:26 am

@Drca: Text.TextWidth should be the actual width using the current font's size.
You may need to add a "Wait 0 sec" system action between the change of the text's content and the Text object's size.
The command will skip a frame, update the content, and return the appropriate size of the new content.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Tue Oct 11, 2016 12:49 pm

Message: Drca can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
@Kyatric

Thank you! When I call upon the TextWidth expression in a new, empty construct project, it works fine, but I can't seem to get it working in my project. Is something overriding it? What am I doing wrong?

Here is the .capx file
https://drive.google.com/open?id=0B1JGt7XBcimrMDRlRXhCcDIzblE

Thank you!
B
4
S
1
Posts: 7
Reputation: 314


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests