[Extension Suggestion] Can anyone make an extension where there is a common block for event?

It might be possible to listen to their events through an extension.

could anyone send me the extension what i asked for?

no one has made the extension you are looking for yet, i may try it later

I'm not sure what you are requesting right now is possible with extensions. The event dispatch system works by matching on (component, event) tuples and executing the corresponding handler, if present. The generic event functionality used by the any component blocks had to be patched into the existing system and requires changes to both the Java code and the Scheme code in runtime.scm. The two parts of the system in question aren't modifiable by extensions, i.e., it will require a modification to core App Inventor to support this.

1 Like

Hi @ewpatton i am thinking this might be possible just need a way to get all components in screen . is this possible?

nb188 has the ability to list the direct children of a form, so you can enumerate all of the components by walking the tree. I don't know how this will interact with extensions that dynamically create components though.

3 Likes

umm then why asking for aix -

all the components are declared as fields in the ScreenN class that extends the form, to that there is a ModuleMethod of events that holds the ModuleBody I tried to change that, but it resulted in an infinite loop

One possibility is that you've made a loop by catching all of the events and reporting them via your new extension's event block, which will trigger your code again, ad infinitum. Your extension is observing the same system it's a part of and therefore things can get tricky.

Another approach might be to replace form$Mnenvironment with a special subclass that will return a function object that can be applied when an event name style signature is detected. Again, you'll want to make sure you aren't reporting your own extension's events otherwise you'll get stuck in an infinite loop (or stack overflow, killing the app).

4 Likes

For extension developers who are going to try to make this extension.
My suggestions -

  1. First get all components
  2. run a loop through components and use reflection to get functions which has SimpleEvent annotation
  3. Then use this method -
    Listen for event dispatches in component through the extension - #34 by ewpatton

no that'll probably not work

1 Like

Why? i thought it was supposed to work, can you tell me the reason maybe it will help me to find a better solution.

The theory works, but only if you are assuming base App Inventor, and if you correctly handle the self dispatch problem. If you want to interact with any extensions that provide the ability to create components at runtime you will only get a snapshot of the available components.

3 Likes

i was able to modify the Environment and listen to the event calls and that wouldnt change any event behaviour, is there anyway to check if Symbol belongs to an event? Currently im just manually checking the names of Symbols, because incase ill need to loop around the components and there might be a problem


Not sure, but i belive so

I said use reflection to check if method has SimpleEvent annotation

1 Like

If I were building this, I would check whether the name of the symbol in question starts with "any$", which is the event signature of the any component event blocks. Generic events always attempt to fire even if the event isn't defined. You could then schedule a new runnable on the UI thread to trigger the extension's event that represents the übergeneric event. You'll want to trap on "any$ExtensionType" where ExtensionType is your extension's type otherwise you'll end up creating an infinite loop.

4 Likes

Hmm unfortunately it seems you can only listen to just event calls but you cannot access (if the event isnt dragged into the blocks section) their args as ModuleMethod isnt defined.

1 Like

Looks like someone has indeed made an extension :wink:

2 Likes

Haha a lot of effort finding what is what

4 Likes

very very useful and helpful extension . thank yoiu

1 Like