How do I identify the type of component?

Here's an alternative approach that converts the component to a string and then decomposes the resulting string into the simple component type name:

This function takes a component block and returns a string that is the code name of the component's type (e.g., Button1 => Button). This will also work with types defined by extensions.

Note: You can drag this image into the App Inventor blocks editor to add it to your project.

7 Likes