Button for select/unselect

Hello everyone.
I am making some buttons to select/unselect options.
I am using this block to change the background of the button depending if it is selected or not and to set the variable:

image

Works fine (except that I have to double click at the beginning to get it to start working)
I would like to know if there is a simpler way to do what I am doing (select/unselect) as I have a lot of buttons to add.
Thanks

1 Like

Hi there,

These are the correct blocks to use.

If you have many Buttons in your project, you can make things easier by using Any Component blocks to make generic blocks that fire when any Button is pressed.

You can use blocks like this to update the Button colors/their corresponding variables when Buttons are pressed:

In this example, I also add the selected items to a list and display them in a List Viewer:

You can see a demo of this here.
.

2 Likes

Thanks!

1 Like