How to obtain the name of a button dynamically?

Hi, all.
I need your help, please. Do you know how can I obtain the name of a button when I do click on it. Not the label, but the name (Button1, ButtonX...).
Thanks in advance,

You can rename the button below there is a button (rename).

  1. Click on the button, for which you want to rename
  2. press the (rename) button

image

This tutorial can also help you :

Hi, Salman_Dev,
Thank you for your answer but I expressed wrong. What I need is to obtain the name of a button dinamically, I mean, when the app is running. I need it in this way because depending the name of the button clicked I have to put in other button an image or another.
I changed the title of this post.
Thank you very much again. Best regards,

Say you have 2 buttons,
When the first button is clicked you want to perform ABC actions and when second button is clicked, you want to perform XYZ actions.
For this you can use the Button's onClick event (When ButtonX.click) to perform the required functions

do you mean like this :

blocks

Thank you, Alaqmar_Bohori and Salman_Dev for your help.
In my app I have 24 buttons calling each one to a radio station (emisora). Each of them, depending on its status (on or off) must have an image or other. You can view the code that I have written in the attached file.

But I want to know the name of the button clicked and resolve the name of the image in both functions, in this way I can delete the variable "emisora_in" in the code of the button.

Best regards,

What, you are using ThunkableX

ha ha ha... yes but not... I've done this app in ThunkableX and now I am adapting it to app inventor

In fact, the firs version was written in App Inventor 2

image

Simplest option

Ooo :grin:

Thank you for your answer, Alaqmar_Bohori, I'm going to try to understand how your code works, I'm a newbie and I need to testing it (test and fail method :frowning_face:)
Best regards,

It's simple, whenever any button is clicked, the name of the button gets stored in variable name, so you can use variable name for whatever you required the components name

That's fantastic Alaqmar_Bohori, this is exactly what I need. Thank you very much again (and for Salman_Dev too).
Best regards,

You're welcome @No_me_gusta_Linux :wink: :+1:

You are welcome!!

You may want to read this in relation to the any component blocks:

http://ai2.appinventor.mit.edu/reference/other/any-component-blocks.html

especially the alreadyHandled argument

1 Like

Thank you very much @TIMAI2, it really helped me

Thank you very much, @TIMAI2, I'm going to read it just now.
Best regards,

P.S.: I've just learned to reference to a forum member :grinning:

For which there is absolutely no need to do when replying to a forum member in a topic !!