Please help me.
How do I create a code block to get a click event on a dynamic component that has been created using the click tools.
Store the Component that you've created in a variable. Invoke the When Button.Click (under Any Components) event on that component:
I will try it
did it work? if it worked, please click solution.
What I mean is different from what was conveyed by @nishyanthkumar So far I haven't found the answer.
please do not spam the community and be patient until you get an answer...
Taifun
Do you need to make a static invisible button on the screen first so that you can use "when anybutton.click" and the green button1? Thanks
With DCLite a real button was required yes.
This gives access to the anycomponent blocks, which are needed.
this can be a string 'Button'
or button
, works for me as well...
First Thanks a lot for your great extension. Regarding your response, are you saying that the green "button1" does not need to be the one dragged from button component, it can simply be a string containing the base word 'button' or 'Button' (maybe they are the same)? In addition, in examples, we see only one dynamic button used. I wonder how convenient it is to use it for multiple components e.g. let's say a few dynamiclly generated layouts, each containing a label, a list picker and a button. Using DCLite, i would think, the first thing is to get the number of layouts i need to make, then initialize that number of lists. Then for each layout, i dynamiclly generate a label, listpicker and button so that all these dynamiclly generated items are put in a list. Then when a button is clicked, I get the name of the button, then look up which list contains this clicked button, then I get the listpicker value from that list. Is there an even simpler approach using DCLite for this purpose?
Thanks for confirming
You may want to use the main dynamic components extension for what you intend, you then can generate id's for each component and use them for selection in the any component blocks.
that's what i am trying, i have ids in the format of e.g. button2 (2 indicate the 2nd layout). is there a way to extract the number from a number-containing-string in App inventor?
AI2 will treat numbers as strings and strings as numbers automagically, but you can always check with the isNumber block on a string. If this returns as false then edit the string and/or multiply by 1.
oh, just see your post in another post to remove letters from a string. Thanks!