JavaScript - Get "this" name
Answered
Hello.
I use the click tab of scripts. I would like to automatically have the name of the object where the script is used. I am looking for a kind of this.name functionality to get the name of the object. How can I do that?
polyname = "test"; thiscol = ggbApplet.getColor(polyname); if (thiscol == "#000000") { ggbApplet.setColor(polyname, 255, 255, 255); } else { ggbApplet.setColor(polyname, 0, 0, 0); };
Files:
ascii-click.ggb
My idea is to build a grid with clickable squares: clicking on the square will toggle its face color (black <--> white).
The "Me" ("this") object exist only in GGB-Script (with the name: %0)
Depending on what you want to achieve, there are shure better solutions.
For further support it is advantageous if you describe the problem (over all) to be solved.
----------------------------------------
sorry I see your description of the problem (in your last post) too late (time overlap)
Shortly I will send a solution without JS.
If you use the spreadsheet then you can make it quite efficiently eg https://www.geogebra.org/m/KwXttZ87
All most done...
I update texts from JS but the back returns are not automatically printed.
See the file joined where I need to double click on each text to see the back returns.
Can this be fixed?
You are using clasic version 5.0.581.0
This is a very old version that I cannot reproduce.
With my system (classic version 5.0.620 Windows10) I can't find the described error with your file. The different codecs are updated continuously.
Install version 5.0.620 and test again.
If the error still occurs: Describe your system environment (e.g. Windows 10 64 bit, ggb version 5.0.620.0-d Java 1.8.0_161-32bit). You can find the information in the menu Help/About License.
If I understand you correctly:
The update of the 6 objects basicbincol, basicbin, chessc0ordwhite, chesscoord, faxlikecol and faxcol is executed only after another click on one (same?) cell. In other words: the display lags one click cycle behind (?).
I can't test it because I don't have a MAC. So I guess:
try:
write after the last line: ggbApplet.evalCommand('UpdateConstruction()')
If unsuccessful: use inside evalCommand('.....') the SetValue() method instead of the assignment with "=".
check also with the version 6.0-WEB: https://www.geogebra.org/classic
In my environment I see no errors when I do this with firefox or chrome. The 6 textfields are updated synchrone with click.
When you have no errors with 6.0-WEB then the possibility of an GGB-bug is big.
What is also possible: I see not the error or you see a error where there is none (what is very difficult to "find")
Comments have been locked on this page!