How do I adjust/scale text object automatically accoding to textbox's input?

0 favourites
  • 3 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • I know how to display a text in a text object from a textbox. However, the input may vary, sometimes it can be longer, sometimes shorter. What I would like to do is to make the text object somehow recognize the font size as well as the length of characters and scale itself to fit the content passed from the textbox and display it neatly and efficiently in terms of space within the text object. In other words, i would like the text object to fit/scale istelf automatically to the content being typed by the user and the font size chosen by the user. Please provide the example or share a screen shot/s if possible.

  • Resizing text objects dynamically is surprisingly difficult.

    You need to make the text field big enough to fit the entire text, then set text. Then wait a little for the system to render it, measure the text using TextWidth and TextHeight expressions. And only then you can resize the text object.

    It's probably better to do the rendering/measuring with a different (hidden from the player) text object. See this post for some examples:

    construct.net/forum/construct-2/how-do-i-18/creating-appropriate-sized-spe-128993

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you for your exhaustive answer. It seems I should manage to make it work with the information you provided. You are incredibly knowledgeable in the field!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)