ID needs to be an Integer instead of a String.
Wow, thatâs realy GREAT stuffâŠ
but I have - maybe a silly - question. How to get eg a click event (or any event) from dynamic generated buttons? ?
I made the Button1 invisible, generate 5 Button, set the text of the buttons to "Button #1âŠ#5 (works fine) and use the âclick eventâ from button1 because i found nothing else. The label is olny for recognition, if an event has been fired - but i can click any of the 5 buttons and nothing happend.
Whats going wrong in my head???
Please help.
Greetings
Looks like AppyBuilder donât have generic events commit from App Inventor. Please move your project to Kodular as AppyBuilder wonât receive updates.
Tremendous - works perfect!
Thank you very much
Oh, Ok! Makes sense. Then I sort of âtranslateâ that integer to the real id component with the GetComponent id block. Thatâs where my confusion was. Thanks, itâs so easy now. I spent a lot of time creating sprites before!
Youâre welcome! I thought Integers are more memorable, so thatâs I used Integers for ID to follow the Kodularâs Dynamic Component guideline.
But I can always replace it to a String on request. (which wonât break existing projects)
I actually need this feature to identify my components properly since its handled through âanyâ events instead of specific components
You can identify your components with GetId
block. It returns the componentâs id which you used in Create block by passing the componentâs itself. If the component is not created with Create block, it returns -1.
GetId block -> Asks for component and returns its ID.
GetComponent block -> Asks for ID and returns the component.
Generic events return the componentâs itself. So you can connect it directly to GetId block to learn which X component is clicked.
I am still a little confused, can you post the picture of the block?
Edit:
This?
Also I have two card components that are supposed to refer the different lists when clicked⊠So i would require more than an ID as there can possibly be two of the same ID
No, ID canât be duplicate. Try creating two components with same ID. It will give an error if you do that. ID is always unique. Otherwise adding an ID feature would be useless.
I added a picture to old post.
You can add a 0 number to the end of id if you want to create a parent component and inner components, so you wonât need two instances of extension.
For example,
Label = 1
Button = 10 (Get Labelâs id and join â0â with Text Blocks)
CardView = 100 (Get Buttonâs id and â0â with Text Blocks)
You can parse them again by removing the last characters.
Can do⊠However a string option would be nice for better identification
Ok then, I will update the extension which allows every type of object as ID along with some improvements.
As you can see GetComponent expects an ID, not the component because you already have the component, replace the block with GetId block, not GetComponent.
Oh
Could this extension be used to create global variables that are pulled from a list or is this only for things that can be interacted with such as buttons?
It is only for components, you should use TinyDB as storing variable values, as it can hold more than one data.
I created 3 dynamic buttons how do I make each button do a different thing because when I use the block Any button all do the same thing