How do I find out what is the type of a component using the component block dynamically? Suppose if I receive a component, is there any way to know weather it is a label or a button or an image or something else?
this is not available as built in functionality
also I do not know, if there is an extension, which is able to do it...
to find it out manually you could put your label components into a list, put the button components into another list and the image components into a third list, then check each of the lists if you can find a specific component in one of the lists... if you find it in the label list, then it is a label, etc.
Taifun
Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.
Here is a sample app using Taifun's technique ...
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.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.