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. 知识库
  3. 二维积木
  4. 按钮控件

按钮控件

Scheduled Pinned Locked Moved 二维积木
1 Posts 1 Posters 902 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.
  • C Offline
    C Offline
    creaticodeteacher2-mail
    wrote on last edited by admin
    #1

     

    先修科目

    • 标签控件
    • 设置控件上的文字

     

    介绍

    你可以在舞台上添加按钮,并指定当用户点击按钮时会发生什么。

     

    添加按钮

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/9e5f39b2-73f7-4524-8f84-5b2a2ad0a866.png" width="700" style="">

     

    参数

    • 按钮上的文字:按钮上显示的文字。
    • 中心位置:按钮中心点的x坐标、y坐标。
    • 尺寸:按钮的宽度和高度。注意,按钮的尺寸不能超过舞台,舞台宽度480、高度360。
    • 提示信息:当鼠标在按钮上悬停时所展示的文本。常用于在用户点击按钮之前展示按钮的功能信息。
    • 按钮名称:名称必须唯一,之后用名称引用该按钮。

     

    编排按钮点击事件

    每当点击按钮,这个积木就运行它下面的代码。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b554c78c-74c5-44ef-ab30-af926555a6ee.png" width="250" style="">

     

    参数

    • 控件名称:需要选择鼠标点击事件所关联的按钮名称。必须先把按钮添加到舞台中,其名称才会出现于下拉列表中。

     

    范例

    下方录屏展示了如何添加按钮,以及每当用户点击按钮,上面的文字就会改变。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f27e0a42-c2e7-4e39-940a-dd93be84cd49.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">

    为了使文字在“开始”和“停止”之间切换,用一个变量“命令”来跟踪当前命令。每当点击按钮,我们就根据“命令”的当前值更改“命令”。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/fb7bcc8f-2608-47f5-986e-ca96ca33380a.png" width="700" style="">

     

    亲自尝试

    https://play.creaticode.com/projects/9569e7bf0eb49d0afa9aa99a

    1 Reply Last reply
    0

    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