Properties
Similar Topics
Statistics
Comments
2
Participants
3
Subscribers
3
Votes
1
Views
811
Share
Answered
When I create an object, I want to automaticlly get an object that is symmetrical to the created one about the Y-axis. But I get caught in an endless loop when using js script as below.
How to listen Add event only once. Please help, thanks.
function ggbOnInit() {
ggbApplet.registerAddListener("AutoSym")
}
function AutoSym(obj) {
ggbApplet.evalCommand("Reflect("+obj+", yAxis)")
}
- 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
Problem 1
All (?) processes in GGB run asynchronous/parallel. That means: if a new object is created in an AddListener function, this happens immediately and parallel to the actual running AddListener function with an additional concurrent AddListener function (instance)
Solution: unregister the add listener before creating the new object.
.
Problem 2
If only one object is created, then the AddListener can be registered again immediately after the creation of the (mirrored) new object. But if more objects are created (e.g. sides of a polygon) then the re-activation of the listener must be delayed. To my knowledge there is no synchronization command for this. As a workaround I would create a timeout.
.
Problem 3
Not all objects can be mirrored. The corresponding object types are not allowed to be handled in the AddListener function.
Problem 1
All (?) processes in GGB run asynchronous/parallel. That means: if a new object is created in an AddListener function, this happens immediately and parallel to the actual running AddListener function with an additional concurrent AddListener function (instance)
Solution: unregister the add listener before creating the new object.
.
Problem 2
If only one object is created, then the AddListener can be registered again immediately after the creation of the (mirrored) new object. But if more objects are created (e.g. sides of a polygon) then the re-activation of the listener must be delayed. To my knowledge there is no synchronization command for this. As a workaround I would create a timeout.
.
Problem 3
Not all objects can be mirrored. The corresponding object types are not allowed to be handled in the AddListener function.
Problem 4
Double, or more the one, addlistners makes no sense in my eyes?
Problem 5
all new created objects become reflected, is this really intended?
perhaps selection by ggbApplet.getObjectType(o)
Comments have been locked on this page!