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. Knowledge Base
  3. 2D Blocks
  4. Dropdown Widgets

Dropdown Widgets

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 1.0k 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.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

     

    Prerequisite

    • Introduction to Widgets with the Label Widget

     

    Description

    Dropdown widgets allow the user to select an item from a list of choices. It is easier to use compared to asking the user to input the choices in a textbox, and it also occupies less screen space compared to adding a button for each choice.

     

    Adding the Dropdown Widget

    You can use this block to add a new dropdown widget:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/62abd0ef-6da3-4c03-9b97-d46175f4be4c.png" width="700" style="filter: drop-shadow(0.35rem 0.35rem 0.4rem rgba(0, 0, 0, 0.5));">

     

    Parameters

    • Center Position: The x and y positions of the center point of the dropdown.
    • Size: The width and height of the dropdown.
    • List: To specify the list of choices, you first need to create a new list, and put all the choices in that list. After that, you can specify that list in this block. For example, you can create a list named “gender”, and add 2 items to it: “Boy” and “Girl”. Then in this block, select “gender” after “using list”.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/94544c40-6ad0-49c5-9e23-248c2491695e.png" width="800" style="margin-left: 40px; border-radius: 5px; border: 1px solid #29622d;">

    • Widget Name: The name of this dropdown, so that you can refer to it in other blocks.

     

    When the user selects an item in the dropdown

    When the user makes a selection, our program needs to respond to that. You can attach your code to this hat block:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/0f856e05-16cf-47ba-bf08-c1f44ccdc64b.png" width="400" style="filter: drop-shadow(0.35rem 0.35rem 0.4rem rgba(0, 0, 0, 0.5));">

    Note that you first need to add the dropdown widget to the stage. After that, you can choose that dropdown’s name from the “Please select” menu in this block.

     

    Selected Item in the Dropdown

    To find out which item is currently selected in the dropdown, you can use this reporter block:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/47701176-b93f-4297-9466-b844c31d3035.png" width="500" style="filter: drop-shadow(0.35rem 0.35rem 0.4rem rgba(0, 0, 0, 0.5));">

    Note that you first need to add the dropdown widget to the stage. After that, you can choose that dropdown’s name from the “Please select” menu in this block.

     

    Demo

    In this demo, we add a dropdown named “menu1” with 2 choices. Whenever the user changes the selected value, we show that value in an alert window.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/fc124063-28a0-45bc-965c-dcede37ef558.gif" width="1000" 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