Button Command (ggb script or JS script) for action on selected objects)
lewws shared this question 2 years ago
Need help with this.
I want student to mouse select a disc (object is a circle). Then click on button(s)
(a) delete the selected disc (1, -1, x, -x discs)
(b) replace with another disc of opposite sign .
Can't find solution to implement using Geogebra script.
2nd problem : I have generated new discs using counters for each type of discs
d1n, dneg1n, dxn,, dnegxn numerical variables to generate unique discs for (1, -1, x, and -x)
But after deletion the acccumulated values of d1n, dneg1n, dxn,, dnegxn are not reduced.
Can possible help me solve how to delete the unwanted numbers?
Use lists for d1n, dneg1n, dxn,, dnegxn?
Thanks in advance.
Questions about the understanding:
1) When 1 disc is created, 1 disc is always erased. Correct?
2) If 1) = Correct: then the number of discs always remains == 4
and only the sign in the caption changes. Correct?
2b) Then why does it need a sequence number as a suffix to the disc?
3) If 1) not correct: The number of discs increases, a sequence number is required as suffix. Correct?
4) If 3) = Correct: should it be possible to delete discs by the user?
5) If 3) = Correct: where should the new (additional) discs be placed?
6) If the sign changes then the color changes as well. Correct?
7) Is a solution possible where the disc is clicked instead of the buttons?
8) The 4 pictures are created with the definition of the buttons, otherwise they are not needed. Correct?
Is it possible that the properties of a selected disc can be changed by clicking on it , but with the script not written inside of the object's "OnClick" properties?
This is the main difficulty with the activity I am working on above.
I think I have understood the task (as follows)
If necessary, please make corrections and/or deletions/additions to the above text.
Point 4 is the one with your most interest
I am absent today (20.12.03) I will probably have a solution tomorrow.
My solution in the attachment.
Not so nice for you because all is new. But I think it is the only reasonable way.
The basic difference: The properties are own objects. That means: you can query and change them and they can have mutual dependencies to all other objects (!). This makes it possible to get along without scripts in generated objects, which seems to me to be the most important point.
I used JS as less as possible. The generated objects have no scripts. But the listeners Remove and Click exist. The index is the same for all disc types.
Comments have been locked on this page!