JavaScript API Example: registerAddListener()
Here is the code which:
- Registers the listener function (called "listener")
- Each time an object is made, adds it to the list (if it's a Point).
SetValue[]
makes the list static. You could use Append[]
if you want a dynamic list insteadfunction ggbOnInit() {
ggbApplet.registerAddListener("listener");
}
function listener(obj) {
if (ggbApplet.getObjectType(obj) == "point") {
ggbApplet.evalCommand("SetValue[list, Length[list] + 1, " + obj + "]");
}
}