Draw line only through existing points

DOS autori shared this question 4 days ago
Needs Answer

Hi!

Is there a possibility to draw line only through existing points? I tried to create tool but iz also didn't work.

I would like to use tool only on existing points and not allow users to create new points when drawing with line tool. For example, just A, B, C and D to be on screen and user can only draw lines through these four points and not ot draw more points when using line tool (blue dots).

Is this possible to do in some way?

Thanks!

9ffd79c71540fc71f4bd2ce4b013d9ba

Best Answer
photo

you can use the attached boolean "crePnt" include his java script onUPdate

and inclued the global java script

Note: use the setting "Java Script" instead of "GeoGebra.Script" at bottom of the script-editor-window.

Comments (8)

photo
1

You can create a custom tool and remove the normal line tool fron the toolbar. You can remove whatever existing tool from the toolbar, acoording to what you want to create or prevent.

chris

photo
1

In your tool you can still create new points with this custom tool. E and F were created with this new tool and I would like to avoid creating new points.

50a28887a88dcfc1172706a4320071cb

photo
photo
1

esto no servirá porque las herramientas crean los puntos que sirven como entrada para la propia herramienta

puedes hacer un script on click en cada punto y un booleano que indique que el punto ha sido seleccionado

de forma que cuando hagas click en el punto se ponga el booleano en true y a continuacion se ejecute un script que haga la recta sobre los dos puntos que tengan el booleano en true

pero ya Rami se me adelantó y lo dirá/hará mejor

photo
2

you can use the attached boolean "crePnt" include his java script onUPdate

and inclued the global java script

Note: use the setting "Java Script" instead of "GeoGebra.Script" at bottom of the script-editor-window.

photo
1

This could work! Now I just have to figure out how this work to implement this kind of solutions in the future :-D !

Thank you!!

photo
1

This could work! Now I just have to figure out how this work to implement this kind of solutions in the future :-D !

Thank you!!

photo
1

create a boolean with name crePnt

copy in script on Update of crePnt the following


pnt = false
if (ggbApplet.getValue("crePnt") == 1) pnt = true
ggbApplet.setOnTheFlyPointCreationActive(pnt)
Select "JavaScript" at the bottom of the editor window.

Choose the tab Global-Java-Script

copy in GlobalJavaScript the following


function ggbOnInit() {
     ggbApplet.setValue("crePnt", 0)
}

Depending what you want as value in prePnt after open the applet use 0 (for false) or 1 (for true) in the second line above.

prePnt can be changed manually (with click). Then prePnt must be visible.

prePnt can be changed with the GeoGebra Scipt "SetValue(prePnt,<true or false>)". In this case prePnt can be visible or not.

I think in most cases you will use crePnt as in the example. But don't show crePnt (hidden). Only if you change the code you will show crePnt (visible)

By the way: the tool "Intersect" and the tool "point" creates points even with prePnt=false

I think the tool "point" must be hidden in the tool-box (and some more). Possibly you may need to create a point tool in its place that can set a point to a specific path-type.

photo
1

Well, first I thought I'll do it the same way you described but in the end I didn't even have to create logical value crePnt. I just put ggbApplet.setOnTheFlyPointCreationActive(false) into Global JavaScript in ggb.OnInit :-)I need only line tool so student can draw all possible lines through given points. This works perfectly!

photo
© 2019 International GeoGebra Institute