How do I use text entry objects in G develop?

I wanna know how you use text entry objects for typing in game. I’m a bit confused about how you limit the amount of words you can type and how you hit enter to start a new line of text. How do I use this?

Check out the Text Entry Object here: https://gdevelop-app.com/game-examples-starters/

Limiting characters is going to be a bit more difficult. You’ll need to use some events to to the following:

  1. Store the text entry as a text object to display your text. (Shown in the example mentioned above). As far as I know this will already take new lines/enter key presses into account.
  2. Set up an event with a condition compare the length of the Text Object to however many characters you want it to have.
  3. You’d then have a sub event that basically has a condition of “If Backspace key is pressed (inverted)” and “Trigger Once”, then an action that disables text entry on your text entry object.
  4. Then another subevent (of #2 above) where you’d do “If Backspace key is pressed” and “Trigger once”, then an action that enables text entry of your text object as it should start deleting the extra characters.

You’ll need to play around with the expression editors and events to get this exact, but it should function.

1 Like

To compare the length, do I use “text in memory”

You could, but it may be easier to use the “Length of a Text” expression and point it at your text object (not text entry object)

I can’t find the “Length of a text” expression. Do I use the condition “Compare the text”? Where do I find that expression?

Here’s what my events look like. Did I do something wrong?

Ah, I see what’s happening, you want to use a different condition. Use the “Compare 2 numbers” condition.

Then, you’ll be able to see “Length of text” as an option in the expression builder.

Okay but what 2 numbers am I comparing? The only number I can think of is the max amount of characters the user is typing into the text. Also I apologize that I keep on asking questions haha

You’re pretty close.
One of the numbers is the length of text. The other number is the max amount of characters you want to allow.

And don’t worry about questions, this is literally a forum for questions. I just may not be able to answer all of them.

1 Like

I got it!!! Thank you so much. Here’s the final results.

1 Like

Congrats! Glad it worked.