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 746 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/a1f9f51f-59b7-48b7-b4ab-d4cb21c83d92.png" width="700" style="filter: drop-shadow(0.35rem 0.35rem 0.4rem rgba(0, 0, 0, 0.5));">

     

    参数

    • 中心位置:下拉菜单的中心的x坐标、y坐标。
    • 大小:下拉菜单的宽度和高度。
    • 列表:为了指定选项列表,首先需要创建一个列表,并把所有选项放到这个列表中。之后就可以在该积木中指定这个列表。比如,你可以创建一个列表“性别”,并加入2项:“男生”、“女生”。然后在这个积木中“使用列表”后面选择“性别”。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/fcf8e62f-adbd-4907-8bbd-0e167ff6e46c.png" width="800" style="margin-left: 40px; border-radius: 5px; border: 1px solid #29622d;">

    • 控件名称:下拉菜单的名称,以便于在其他积木中引用它。

     

    当用户在下拉菜单中选择一项

    当用户在下拉菜单中选择后,我们的程序需要对此响应。你可以把代码放到这个帽子积木下面:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/e0f983ab-873c-4b14-9fed-7f2fb8ff8caa.png" width="200" style="filter: drop-shadow(0.35rem 0.35rem 0.4rem rgba(0, 0, 0, 0.5));">

    注意:你需要先把下拉菜单控件添加到舞台上,然后才能在这个积木的菜单“请选择”中选择下拉菜单的名称。

     

    从下拉菜单中选择选项

    为了找出下拉菜单中当前选中的是哪一项,可以用这个报表积木:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/6a466cfb-4c85-44a5-b807-5ae908fe7005.png" width="200" style="filter: drop-shadow(0.35rem 0.35rem 0.4rem rgba(0, 0, 0, 0.5));">

    注意:你需要先把下拉菜单控件添加到舞台上,然后才能在这个积木的菜单“请选择”中选择下拉菜单的名称。

     

    示例

    在这个示例中,我们添加一个下拉菜单“菜单1”,有2个选项。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/d1cde62a-8f52-42c7-96fc-92e1b7a8b989.gif" width="1100" style="border-radius: 5px; border: 1px solid #29622d;">

    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