Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gdevelop5:objects:text_entry [2017/11/08 21:57]
4ian [Add text entry object]
gdevelop5:objects:text_entry [2020/12/26 13:56] (current)
Line 1: Line 1:
  
-==== What a text entry object is ====+# Text entry object
  
-The text entry object allow us to capture user input and store it in memory. We can use this object to simulate text input fields where the player can enter for example a player name.+<note tip>**See it in action!** 🎮\\ 
 +[[#Examples|I would rather see the Sprite object examples! Please take me there now.]] 
 +</note> 
 + 
 +The text entry object captures user input and stores it in memory. You can use this object to simulate text input fields. For example, you might use the text entry object to provide a way that the player of your game can enter his/her name or any other information.
  
 ==== Add text entry object ==== ==== Add text entry object ====
  
-To add text entry object we need to select it from the list when we create a new object +After creating new object from the Objects Editor list, select "Text entry" from the displayed list of choices 
-You may need to scroll down on the list to find it+
 {{ :gdevelop5:objects:add-text-entry-object.png?nolink }} {{ :gdevelop5:objects:add-text-entry-object.png?nolink }}
  
-After, rename the object to whatever you like and simply add the object to the scene. Now if you run a preview all the keys you press is going to be captured by the object and stored in memory. In order to read the value from the memory you need to use an expression which take the form **object_name.String()**+Rename the Text entry object to whatever you like. Add the Text entry object to the scene. 
  
-You can learn more about expression on the wiki+Now, if you run a preview of the scene, all the keys you press are going to be captured by the object and stored in memory. In order to read the value from the memory, you need to use an expression like this one: `TextEntry.String()` (see an example below).
  
 ==== Display value using a text object ==== ==== Display value using a text object ====
  
-Let add a text object to our scene. After let add an event to modify the text of the text object +First, add a Text Object to the scene. Then, add an event to modify the content of the Text object
-{{ :gdevelop5:objects:text-entry-object-display-value.png?nolink&400 |}}+ 
 +{{ :gdevelop5:objects:text-entry-object-display-value.png?nolink }} 
 + 
 +For the last parameter, which is the new content for the text, use the expression mentioned above: 
 +{{ :gdevelop5:objects:text-text-entry.png?nolink |}} 
 + 
 +<note>__Entry__ should be the name of the Text Entry object. You need to replace this with the name of your Text Entry object.</note> 
 + 
 +Now if you run a scene preview. Start typing you will see the text object displaying whatever you type. 
 + 
 +Using events, it is possible to enable or disable the "Text entry" object. Events also allow you to control when to capture text input and when not to capture text input. 
 + 
 +{{:gdevelop5:objects:textentryobjectevents.png|}}
  
-After we just simply need to use the above mentioned expression as the text 
-{{ :gdevelop5:objects:expression-get-text-entry-value.png?nolink&400 |}} 
  
-//Note that, __text-entry__ is my choice of name for the text entry object. You need to replace that with the name of your text entry object.//+## Examples 
  
-Now if you run a preview and start typing you should see the text object displaying whatever you type.+<note tip>**See it in action!** 🎮\\ 
 +Open these examples online.</note>
  
-Using events we can enable, disable the text entry object whenever we want and control it this way when we actually capturing input and when not to. We can also modify the value stored in memory to anything we like+{{:gdevelop5:objects:textexample.png?|}}
  
 +* https://editor.gdevelop-app.com/?project=example://text-entry-object