文本框控件
-
先修科目
介绍
利用文本框可以让用户输入文本,比如评论、聊天消息、数字。 .
添加文本框

参数
- 中心位置:文本框中心的x坐标、y坐标。
- 尺寸:文本框的宽度和高度。注意,文本框的尺寸不能超过舞台,舞台宽度480、高度360。
- 边距:文本的左右边距。
- 行数模式:是只有一行还是可以多行。如果是单行,文字将位于文本框中间,当用户在文本框输入时忽略回车键。
- 滚动模式:如果文本有多行,是否有滚动条可以竖直滑动文本框。
- 输入模式:用户能否在文本框输入,还是只读。
- 文本框名称:名称必须唯一,之后用名称引用该文本框。
读取文本框
可以用这个积木读取文本框内容:

参数
- 控件名称:选择要读取值的控件。对于文本框,“值”就是文本内容。
事件:当值变化
你可以监听事件——控件的值发生变化。对于文本框而言,当其中的文本发生变化,就会触发该事件。

参数
- 控件名称:选择监听哪个文本框的变化事件。
范例
在这个项目中,我们添加一个文本框和一个标签。当我们在文本框中输入内容,其值发生变化 ,当该事件被触发,我们把标签的文本设置为文本框的内容。


亲自尝试:
https://play.creaticode.com/projects/b71c2eef25e72eadcf22ab94
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