Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. 2D Blocks
  4. The Textbox Widget

The Textbox Widget

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 1.2k Views
  • 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.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

     

    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

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1857ce67-9a2c-48a8-91f0-0c1b22b8124a.png" width="1000" style="">

     

    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:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/da2780a7-571a-41d5-808e-59a3af102529.png" width="450" style="">

     

    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.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/0cdf520d-e89a-450f-b43e-35a59b647792.png" width="350" style="">

     

    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.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/6e1913f2-8ee7-48d9-a2b4-c94e06b08123.png" width="1000" style="">

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c7714057-cf1a-412d-85a9-f1e9ac195757.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">

     

    Try it yourself:

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

    1 Reply Last reply
    0
    • CreatiCodeI CreatiCode pinned this topic on

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode