Component variable name for "any button"

Hello,
I have 6 buttons, when i receive a value i want change background color of the specific button.


In component, i know i must make "button 1" or "button2" but is it possible to make a variable, like "button x" with x = 1,2,3,4...?

hi, that block is from "any component" so you need to specify wich button you want to modify the background color

Yes
Just create a list having the 6 button components and use the select list item block to select component x from the list, x is the selection index in this case

Taifun

use this the index number will be get by each buttons you have in the every button.

After you have Every button like this below:

Screenshot 2024-09-22 220659

This above is the list of all buttons you have in your pallette.

In this you need to find index number of that button by simply use this in label text or in Companion to find the index number manually.

of button like this below :

If you got the index number then you will able to identify that button and easily change Bacground Color of it without having more complication.
I tried to make it simple for everyone, if you not understood something you can ask me.
Easy to code...

Try this
changeButtonColor.aia (3.2 KB)

for this

This method is too long can you check and correct my method if ay mistake in it.
Your method is working for me, but can you please also check my method also.

Easy to understand

it's work,
Just one last question, how to remember the already colored buttons?
Here, only the last button is colored.

Thank you for your reactivity and your pedagogy.

Use tinyDB if Local Temporary or Use Global Variable,

Use add Item Block when the colored function do, in above blocks I shared.

Oops sorry, :flushed:
thanks too, of course, SteveJG and Taifun.

Yes of course,
I don't have the reflex to put components and their properties in a list.

Mark the solution not talks, This will help others

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.