<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[文本框控件]]></title><description><![CDATA[<p dir="auto"> </p>
<h2><a class="anchor-offset" name="先修科目"></a>先修科目</h2>
<ul>
<li><a href="/topic/580/%E9%80%9A%E8%BF%87%E6%A0%87%E7%AD%BE%E6%8E%A7%E4%BB%B6%E7%AE%80%E8%A6%81%E4%BB%8B%E7%BB%8D%E6%8E%A7%E4%BB%B6">标签控件</a></li>
<li><a href="/topic/615/%E8%AE%BE%E7%BD%AE%E6%8E%A7%E4%BB%B6%E4%B8%8A%E7%9A%84%E6%96%87%E5%AD%97">设置控件上的文字</a></li>
</ul>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="介绍"></a>介绍</h2>
<p dir="auto">利用文本框可以让用户输入文本，比如评论、聊天消息、数字。 .</p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="添加文本框"></a>添加文本框</h2>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/093edee8-ae6d-476c-a12c-75a07a815bf8.png" width="1000" /></p>
<p dir="auto"> </p>
<h3><a class="anchor-offset" name="参数"></a>参数</h3>
<ul>
<li><strong>中心位置</strong>：文本框中心的x坐标、y坐标。</li>
<li><strong>尺寸</strong>：文本框的宽度和高度。注意，文本框的尺寸不能超过舞台，舞台宽度480、高度360。</li>
<li><strong>边距</strong>：文本的左右边距。</li>
<li><strong>行数模式</strong>：是只有一行还是可以多行。如果是单行，文字将位于文本框中间，当用户在文本框输入时忽略回车键。</li>
<li><strong>滚动模式</strong>：如果文本有多行，是否有滚动条可以竖直滑动文本框。</li>
<li><strong>输入模式</strong>：用户能否在文本框输入，还是只读。</li>
<li><strong>文本框名称</strong>：名称必须唯一，之后用名称引用该文本框。</li>
</ul>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="读取文本框"></a>读取文本框</h2>
<p dir="auto">可以用这个积木读取文本框内容：</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/6d1e8eaa-d63c-47cf-ad42-7db8467b9db3.png" width="200" /></p>
<p dir="auto"> </p>
<h3><a class="anchor-offset" name="参数"></a>参数</h3>
<ul>
<li><strong>控件名称</strong>：选择要读取值的控件。对于文本框，“值”就是文本内容。</li>
</ul>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="事件-当值变化"></a>事件：当值变化</h2>
<p dir="auto">你可以监听事件——控件的值发生变化。对于文本框而言，当其中的文本发生变化，就会触发该事件。</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/822a38fc-7944-4d19-9fbf-93d5d70ba0fd.png" width="200" /></p>
<p dir="auto"> </p>
<h3><a class="anchor-offset" name="参数"></a>参数</h3>
<ul>
<li><strong>控件名称</strong>：选择监听哪个文本框的变化事件。</li>
</ul>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="范例"></a>范例</h2>
<p dir="auto">在这个项目中，我们添加一个文本框和一个标签。当我们在文本框中输入内容，其值发生变化 ，当该事件被触发，我们把标签的文本设置为文本框的内容。</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c835bcdd-ab65-4d4d-ae07-9d01a7dd2f95.png" width="1000" /></p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/db811ae1-d299-466d-8b14-092ce77ee076.gif" width="500" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> </p>
<h3><a class="anchor-offset" name="strong-亲自尝试-strong"></a><strong>亲自尝试：</strong></h3>
<p dir="auto"><a href="https://play.creaticode.com/projects/b71c2eef25e72eadcf22ab94" target="_blank">https://play.creaticode.com/projects/b71c2eef25e72eadcf22ab94</a><br /> <br />
<iframe src="https://play.creaticode.com/projects/b71c2eef25e72eadcf22ab94/embed" width="485" height="402" allowfullscreen></iframe></p>
]]></description><link>https://forum.creaticode.com/topic/619/文本框控件</link><generator>RSS for Node</generator><lastBuildDate>Fri, 08 May 2026 09:09:37 GMT</lastBuildDate><atom:link href="https://forum.creaticode.com/topic/619.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Sep 2022 14:34:03 GMT</pubDate><ttl>60</ttl></channel></rss>