As a coding exercise (which is what Scratch is about, IMO), I created a text editor sprite for re-use in projects. I've seen similar projects however I wanted to make something with proportional character spacing, multi-line editing and good performance. - Free typing of virtually all characters (See notes sections for limitations) - Proportional character spacing - Automatic word wrap - Automatic vertical scroll - Configurable margins - Configurable font sizing and bold face - Configurable text color by using the color and/or brightness effect block. Usage: [ENTER| - Carriage Return (new line) [LEFT ARROW] - Backspace With minor modifications, this sprite can be used for text display only. If your project displays text dynamically, let this sprite can handle the formatting. I have no idea if others will find this useful in their projects. I can anticipate needing it for myself someday. Regardless, it was an interesting thing to do in Scratch. #textbox #text #engine
All the editing logic is contained within this single sprite. It is intended for inclusion in projects that need text handling. This project is only a generic usage of the sprite. See my remix for further demo usage. Comments and Limitations: ------------------------------------- - Extensively uses the Events/Key Pressed block. These work without any Forever loops. The only Forever loop is making the cursor blink. Its very "light weight", so to speak. - Requires [LEFT ARROW] for backspace. At the time of this writing, I could not make either [BACKSPACE] or [DEL] keys work. - Uses the Pen/Stamp block. I tried clones however run-time manipulation of the text (clones) was complex and the need for broadcasts hampered performance significantly. - Stamps only render on the Stage Backdrop. This is a limitation of the Pen/Stamp block. - Stamps are bitmap copies of the vectors therefore the text does not have the resolution of vectors. - The costume for each letter is drawn using the text Sans Serif font. All the character proportions are based on this font. If you use this sprite and want to change the font, the Proportions List must be updated. - Vertical scroll is destructive with this version. Once text scroll off the screen its gone. - Behind the scenes, I have reserved the pipe '|' character to represent carriage return therefore you can not explicitly use this character. - For some reason, the '~' character doesn't work so I left out support for it. Also, the '?' is erratic. Sometimes when entering the '?' character, future keystrokes append the '?' with the desired character. Weird. I attribute these to bugs in the Scratch interpreter.