how to add onclick event on object A by another object B?

邱奕凱 shared this question 1 year ago
Answered

I want to write some Onclick event on object A by another object B.

The questions I face Is that I want to generate some rectangles by a button, then I want to apply Onclick function on those rectangles. So when I click the rectangles it will rotate 90゚.

I have done the previous Step to generate the rectangle by the bottom. But since the rectangle is new object I can't write down the onclick function before it's generate.

So I'm finding some Way to edit the onclick function on rectangles by other object, I have found some JS function like ObjectOnclickListener but I don't really know how to use it as well.

Is it possible to edit by js?


sorry that my English is poor, and thanks for help.

Best Answer
photo

A demo for reference.

Open the attached ggb file and click on the polygon to see the result.

随时中文交流。

Comments (4)

photo
1

Please post your file

photo
1

A demo for reference.

Open the attached ggb file and click on the polygon to see the result.

随时中文交流。

photo
1

It's also possible to have the "rotate on click" behaviour ONLY on the objects you create with the button (via registerObjectClickListener).


And instead of creating copies of the object, it's possible to assign the rotated version back to the original object (but you lose any other dependencies as well).


A demo is attached.

photo
1

Thanks. this is better.

photo
© 2022 International GeoGebra Institute