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. The Radio Button Group Widget

The Radio Button Group Widget

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 782 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

    Introduction

    A radio button is also called an option button. It is actually a group of buttons, and only one of the buttons in a group can be selected. If you select any button, then the previously selected button in this group will become unselected. Radio buttons are most useful when you need to give the user a few choices, but only want the user to pick one of them.

    To add a group of radio buttons, use the following block:

    343093f7-ba1a-4421-8ab2-e46c9ce38091-image.png

     
    Parameters:

    • The 6 inputs allow us to specify up to 6 different choices. If you only want to offer 3 options, then fill in the first 3 input fields.
    • The radio buttons can be arranged vertically or horizontaly.
    • You can specify the position and size of the radio button group
    • Lastly, you can give this group a name.

     
    For example, the following program adds 2 groups of radio buttons. These 2 groups are independent of each other.

    f37cea01-b7a2-40d6-81ac-858c9b6abc65-image.png

     

    rg.gif

     
     

    Set Value To a Radio Button Group

    To make sure one of the radio buttons is selected by default, you can use the “set value to widget” block. You have to use one of the options as the new value:

    f2136a5f-1cf7-41f1-b499-46620805a3db-image.png

      The above program will produce this:

    a1e74875-90e7-4a88-87ea-fb84bc93a065-image.png

     
     

    Handle Value Changes

    To make your program “reactive”, you can run some code whenever the value of the radio button group changes. To do that, you need to use the “when widget changes” block to handle the change event, and use the “value of” block to read the currently selected option of the group.

    For example, the following program sets a different color effect based on the user’s selection:

    rg2.gif

     
    Similarly, the following program changes the sprite’s direction based on the second radio button group:

    rg3.gif

    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