Properties
Category
Spanish
Similar Topics
Statistics
Comments
9
Participants
5
Subscribers
5
Votes
1
Views
1118
Share
Answered
Necesito poder escribir guiones Javascript en la parte gobal, pero no encuentro como hacerlo. he podido crear botones con javascript al clic y también algunas cosas con javascript al actualizar... pero no consigo como hacer por ejemplo que el programa desde el inicio haga que todas las líneas y puntos sean de un tamaño determinado y color. o cosas por el estilo. se algo de variables funciones, arreglos, y ciclos en Javascript... pero no encuentro el modo de manejarme con la zona de funciones globales.-gracias
- GeoGebra
- Help
- Partners
-
Contact us
- Feedback & Questions
- This email address is being protected from spambots. You need JavaScript enabled to view it.
- +43 677 6137 2693
© 2023 International GeoGebra Institute
Basically, Global JS is always inside a function. This Global-JS function can be called from JS which is placed somewhere. Either from the JS in onUpdate or onClick in the objects. Or from the so-called "listener calls" from the kernel of GGB itself.
"Listener calls can be established anywhere in the JS-code by specifying the name of the function to be call in global JS on a GGB-specific (non-object related) event. Usually this "listener-calls" are established within the function ggbOnInit(), which is called by the GGB kernel when an applet is started. Listeners are a very powerful concept, it is worth using JS for this.
The documentation is quite sparse and it is recommended to do several experiments before starting a concrete project. You should always have this documentation at hand. The best way to answer questions is to create and adapt experiments and draw conclusions. GGB-5 and GGB-6 has some (small) differences (I don't know which, because I always use GGB-5).
Most objects and their properties can be accessed via the interface "ggbApplet.<interface>(<parameters>)" (see link above). Some properties must be read and written via XML. Cumbersome conversion procedures are required to access GGB lists.
If there are errors in the global JS, no error message appears and the JS is aborted silently. It is therefore recommended to test a JS function within a buttons onClick before it is established in global-JS.
Larger codings should be created outside the GGB internal code-editor and then copied with Ctrl-C and Ctrl-V into the code-editor.
The alert() command is available for testing (nothing more).
JS is useful in very few situations and is overestimated at the beginning. Usually the disadvantages outweigh the benefits.
Many hours of desperation await you. Have fun.
.
attached a sample with listener
Apreciado Rafael:
Las funciones globales se crean en la pestaña JavaScript global. En la aplicación adjunta puedes ver cómo invocar una función global.
Para que el programa ejecute ciertas líneas desde el inicio, puedes incorporar dichos comandos a la función ggbOnInit (también te puedes guiar por el ejemplo).En mi aplicación, cuando la grabé y cerré, lo hice estando los objetos con sus parámetros estándar (color negro y tamaños estándar). Al abrirse, aparecen con características especiales.
Para evaluar el trabajo de ggbOnInit debes cerrar y volver a abrir el archivo. O bien, puedes crear un botón cuyo guion tenga la única línea:
ggbOnInit();
y lo ocultas al terminar tus pruebas. En la aplicación de ejemplo puse el botón para mejor claridad.
Tips:
https://wiki.geogebra.org/e...
(de allí me guié para la sintaxis de los comandos que asignan color, tamaño y espesor de línea)
Nota: La aplicación de ejemplo ejecuta tres tareas:
Aunque no soy un experto, estoy totalmente a la orden ante cualquier duda que puedas llegar a tener.
Comments have been locked on this page!