How do I see all of a string in a textInput and add spaces?

0 favourites
From the Asset Store
Spaces Ambience contains 102 Sounds: 53 track and 49 sounds
  • I have a read-only TextInput object. I am trying to fit in a 50 character string, but I need all of it to be visible, I can only see about 24 characters. Is there any way I can see all 50 characters at once without changing font size? I figured if I adjusted the height size of the TextInput it may character wrap but it didn't. I also tried using a text object. I can't highlight it to copy/paste it though, like I can with a TextInput object.

    I am open to other suggestions, as long as the user can manually copy and paste the string.


    Solution example is in this c3p.

  • Change type to "Text area" in TextInput properties (on the left panel).

  • Yes, that solved it. I always feel silly when the solution is that simple. Do you happen to know how to add a space or a comma every 3 character spaces? A 50 character string can be hard to read.

  • Are you creating the string to display in this textinput in runtime? You can try something like this:

    Compare two values: (len(TextInput.text)%3)=0 
     TextInput set text to Self.text & " "
  • I made a base converter. I was going to offer an easier way for the user to read this "11100011010111111010100100110001100111111111111111". I was thinking an option to put spaces in it.

    I can read and understand Line 1 and Line 2, but I would like to be sure. You are comparring len(TextInput.text) modulo 3 to Zero? Are you going off of the fact that the spaces will be set when the string is being entered?

    I was wanting to take "1110001" and convert it to "111 0001". I should have been clearer, but what you did is a great idea if I understood that correctly.

  • Are you adding these digits to the string one by one?

    This code works for me:


  • If you already have a string of numbers and want to add spaces to it:


  • That is perfect. Thank you for going out of your way. I will save the images and update a c3p soon so it has both. I need to add this to a c3p tutorial anyway. I understand all of the steps and I just wasn't sure how to go about it. I will be sure to give you credit in a comment and post the c3p link to the original post.

  • Sorry to bother you again.

    Can you explain why

    For "n" from len(s) to 3 works


    For "n" from 3 to len(s) doesn't.

  • Because the string grows when you add spaces to it.

    If your string is 100 characters long, and you start from 3 to 100, by the time you reach 100th character, the string will be ~130 characters long. The loop will stop and the remaining portion of the string will not be processed. That's why I'm running the loop in reverse.

  • I thought that was it, but I wasn't fully understanding it.

    It seems len(s) to 3 is in a feedback loop.

    So why wouldn't 3 to len(s) be in a feedback loop?

    I figured you would want the self adjusting number to be last instead of first.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • len(s) is evaluated only once when the loop starts. If the initial length of the string is 100, then the loop will only repeat to 100, even if the string length changes while the loop is running.

  • Okay, so what I am getting is the start index gets checked each loop and the the end index does not.

    So 'len(s) to 3' works because len(s) is the start Index.


    This post is incorrect. Both the Start index and the End index are only read once. Changing their value after the loop starts doesn't change how many times the loop runs.

  • Not sure what you mean.. If you set A=5 and B=20, then "For A to B" loop will only run from 5 to 20, no matter if you change these variables inside of the loop.

  • I tested and you are right.

    Changing either value once the loop starts doesn't change how many times the loop runs. I thought the start/end index could be updated in loop. I know they can't now, I sadly still have the same question though.

    I am confused on why 'len(s) to 3' and '3 to len(s)' is different. '100 to 3' or '3 to 100' would both result in 97. I figured the only difference is counting up or counting down. Neither start/end index get updated once loop starts, so I don't see how many times the loop runs is different. I feel I bothered you to much on this topic though.

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