You see what’s missing.
Then you search the files in the sources.
There is a github page with all app inventor sources.
There you can look where the file is located.
After you found the file, open it and copy the first line:
In this example for EventDispatcher file: package com.google.appinventor.components.runtime;
Replace then package with import.
Then replace ; with .EventDispatcher;
That is not even remotely obvious to support a comment like this:
To add to that if people are using code from one of the other couple dozen libraries available on IDE, they may not know which library. Is it java.utils etc etc?
The point is, being dismissive does not help. For me, if EventDispatcher is so important, why is it not one of the native imports on IDE? So when I started building with IDE my assumption was that it EventDispatcher was not from AppyBuilder library, and I could not figure it out.
It’s pretty hard for a beginner to understand how library and packages work. They will learn eventually. For experienced users like you It feels easy and simple but for a beginner it’s pretty hard. Your reply will help him out understand about classes now.
Since you’re learning I have a suggestion.
Instead of using an EventDispatcher I recommend:
Replacing “void” with “int” or “double” and “GotResult” with “return”
Something like this: @SimpleFunction(description = “Add two numbers”)
public double Add(double num1, double num2) {
return num1+num2;
}
Thanks @Ken for your suggestion … but, I already know that one which returns value directly from a method. I wanted to know how to make a Event which returns a value.