Control properties of a button from another control

Does someone know if it is possible to change Control properties of a button from another control?
If I have button1,button2,button3,button4 etc
On each onclick I havea Boolean variable say varButton1Clicked,varButton2Clicked,varButton3Clicked etc.
Q: Is there a way to change the property (say backImage or color) from another control ?
eg1-(block code that says if x=2 then change the Button2 background color to black.)
eg2-(block code that says if x=3 then change the Button3 background color to black.)

Yes, it’s possible to do that.

Screen Shot 2019-12-16 at 5.15.43 PM

Or if you prefer, you can use an If block and a condition for x=2, etc.

1 Like

thx - but you have to have a condition for each x.
I was hoping there would be a ButtonX where you have a Button3 above, so the code could be 1 line rather than 20 “Ifs” should there be 20 buttons (button1 thru 20 say).

Yes, you can use the Any Component blocks to code a single rule/if for all blocks in a screen. If you’re going to use a different variable for each boolean, you’d want to use a List instead of individual variables because then you can reference the index number of a particular list item.

I still don’t quite understand what you’re trying to do. Are you wanting a bunch of buttons that when you click each one, they change an associated button’s background color? Is it possible for you to sketch your idea and post it?

best is if you had 2 grids A and B of 49 buttons (7x7) each. Each within a column (1 hidden and 1 NOT hidden). If you click say 22nd button on A then it is easy to get THAT button to show a background pic but want to control (show a background pic say) on the corresponding button (i.e 22nd) on grid B.

You can do that, too. I’d have a demo posted for you but it’s not working when I preview it so let me get back to you on that.

Something like this might get you started?

All the buttons are in the list of buttons in Column1, this means you can use the “first occurrence of in list” block to find the index (number) you’re looking for.

Alright,the blocks are a little messy and I didn’t get rid of the cloner buttons but this will get your started: