Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    The Textbox Widget

    2D Blocks
    1
    1
    381
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • info-creaticode
      CreatiCode last edited by admin

       

      Prerequisite

      • The Label Widget
      • Setting Text on Widget

       

      Description

      You can use a textbox to allow the user to input some text, such as some comments, a chat message or a number.

       

      Adding a Textbox

       

      Parameters

      • Center Position: The x and y positions of the center point of the textbox.
      • Size: The width and height of the textbox. Note that the textbox is limited to the stage window, which has a width of 480 and a height of 360.
      • Padding: how much space on the left and right margin of the text.
      • Line Mode: Whether there is only one line of text, or there can be multiple lines. If there is only a single line, then it will be positioned in the middle of the textbox, and the enter keys will be ignored when the user types in the textbox.
      • Scroll Mode: When there are too many lines of text, whether there will be a scrollbar to scroll the textbox vertically.
      • Input Mode: Whether the user can type in the textbox, or it is read-only.
      • Textbox Name: A unique name to refer to this textbox later.

       

      Reading from a Textbox

      You can read the content of a textbox using this block:

       

      Parameters

      • Widget Name: You need to select the widget to read the value from. For a textbox, its value is the text in it.

       

      When Value Change Event

      You can listen to the event that the value of a widget has changed. For textboxes, whenever the text in it changes, this event will be triggered.

       

      Parameters

      • Widget Name: You need to select the textbox to watch for the change events.

       

      Demo

      In this project, we add a textbox and a label. As we type in the textbox, its value changes, and when that event is triggered, we set the text of the label to be the content of the textbox.

       

      Try it yourself:

      https://play.creaticode.com/projects/b71c2eef25e72eadcf22ab94

      1 Reply Last reply Reply Quote 0
      • Pinned by  info-creaticode info-creaticode 
      • First post
        Last post