How to create and delete free point using JavaScript?

Math123 shared this question 3 months ago
Answered

How to create, delete and selection object point , line, text using JavaScript window.

Pls share the attachment of results..

Best Answer
photo

for (var i =0 ; i<5; i++) {
     ggbApplet.evalCommand('A_' + i + ' = (random()*5 , random()*5)');
}
the first and the last double apostroph must be a single apostroph.

Reason: the whole string is composed of substrings and variables. ('A_' is a substring followed by a variable)

This form is suitable for maximum 0..9 (one digit)

.

The addlistener is not suitable for this purpose at all.

.

Note: the whole thing could also be done in GGB-Script.

Execute(Sequence("A_{"+(n-1)+"}=(random()*5, random()*5)",n,1,5))

Comments (9)

photo
1

1. Point onClick (JavaScript) of button using working fine .

getApplet.evalCommand("A = (2 , 3)")

2. But points are not creating using for loop onClick (JavaScript).

for (var i =0 ; i<5; i++) {

ggbApplet.evalCommand("A_'+i+' = (random()*5 , random()*5)"); \\ or

ggbApplet.evalCommand("A_'+i+' = (Math.random()*5 , Math.random()*5)"); \\

}


3. Also not working in Global JavaScript.

function ggbOnInit() {

ggbApplet.registerAddListener("myFn");

}


function myFn() {

for (var i; i <2; i++) {

ggbApplet.evalCommand("A_'+i+' = (random()*5 , random()*5)"); \\ or

ggbApplet.evalCommand("A_'+i+' = (Math.random()*5 , Math.random()*5)"); \\

}

}


Pls suggest solution for both as well.

photo
2

for (var i =0 ; i<5; i++) {
     ggbApplet.evalCommand('A_' + i + ' = (random()*5 , random()*5)');
}
the first and the last double apostroph must be a single apostroph.

Reason: the whole string is composed of substrings and variables. ('A_' is a substring followed by a variable)

This form is suitable for maximum 0..9 (one digit)

.

The addlistener is not suitable for this purpose at all.

.

Note: the whole thing could also be done in GGB-Script.

Execute(Sequence("A_{"+(n-1)+"}=(random()*5, random()*5)",n,1,5))

photo
1

Thanks rami for the support.


https://wiki.geogebra.org/e...

Is it possible to use purely JS commands / properties/ methods / call back functions/ eventListener in GGB to create objects , strings etc.. other than above link.


Pls answer in detail looking for your kind support here. What is possible and what not possible?

photo
1

I'm not sure I understand the question correct.

But: All ggb-objects can ask / manipulate only with the the interface-commands in your above link. (that's what makes JS in GGB so cumbersome)

photo
1

Is it possible to use JS call back functions/properties and method in GGB-interface by any means whether above link or other way?

Thank you very much for the support and clear the doubts.

photo
2

If call back == give back to GGB:

the answer is NO, no other way then with the interface-commands in above link.

photo
1

Can we use setTimeOut() function by any means.

photo
2

I mean: in GGB5.0 is yes and in GGB6.0 is NO

but for GGB5.0 I don't know how

for timeOut I use allway a slider, this works in GGB5.0 and GGB6.0 (but it is confusing and expensive)

.

Addendum: maybe this link will help (I can't explain this, I need it not because it is only GGB5.0)

photo
1

Thank you very much rami for your time.....!

photo
© 2020 International GeoGebra Institute