controlling "selection allowed" from script

fbeleznay shared this idea 6 years ago
Completed

Sometimes it would be useful for me to be able to change the "selection allowed" status of an object from script. It would give extra functionality to applets I am trying to create.


Would you please consider adding a "SetSelectionAllowed" command to the list of scripting commands?


Also, for a slider and for checkbox if "selection allowed" is deselected, then the state cannot be changed. On the other hand for input box and for drop-down menu I see no difference between "selection allowed" true or false. If the "SetSelectionAllowed" command is implemented, then it would also be helpful for me if the state of "selection allowed" would have an effect on these input methods (i.e. blocking the changes when "selection allowed" is false).

Comments (7)

photo
1

You can do that with the second parameter of setFixed(), try


  1. ggbApplet.setFixed(true,false)

photo
1

Thank you, but can you please clarify this? I may be missing something, but as I understand, "fixed" and "selection allowed" are not the same thing. "Fixed" can be changed from the "basic" tab, "selection allowed" is changed from the "advanced" tab, and they don't change together.

photo
photo
1

hi

they don't have to change together. Fixing overrules 'selection allowed', so you can't change a fixed object, since you can't select it. If you unfix it, then 'selection allowed' is valid back again.

Michaels solution includes that you check 'selection allowed' but at the same time you decide by fixing or unfixing an object if this option is valid or not.

chris

photo
1

Thank you again, but can you please take a look at the applet I attach? It does not work as intended, or I am not doing something right (I tried with the javascript code Michael suggested, but for some reason it does not work for me, so I also tried with the SetFixed geogebra script command).

In the left column all objects are selectable, I am changing the fixed/not fixed status.

  • For points and texts, fixing the object indeed works.
  • For the slider, fixed/not fixed does not have any effect on whether the value can be changed or not. It only fixes/not fixes the position. Also, SetFixed does not seem to change the fixed status of the slider. (as a contrast, a non-selectable slider on thr right cannot be changed)
  • For input box, the content can be changed and it changes the value of the associated object even though both the input box and the associated object is fixed.
  • For drop-down menu, I don't see any effect of either the "selection allowed flag" or the "fixed" flag.

photo
1

I've got no experiece with using javascript, but using ggscript you're absolutely right that the overruling only works with points and texts. The file you included is very demonstrative. Maybe someone could take a look at the scripting possibilities when working with the other types of objects or with javascript

chris

photo
1

The second parameter of JavaScript method setFixed does that. So if you want to disable "selection allowed" of a fixed object A, try


ggbApplet.setFixed("A",true,false);

if you want to do the same for an object that's not fixed, try

ggbApplet.setFixed("A",false,false);

At the moment there is no getFixed method so you need to keep track of what's fixed yourself.

photo
1

Ich would do i in a different way. You can have the same object two times and if one point should not be moveable and fixed, the fixed version should be visible.

If the point should be able to be moved, you show the moveable point and make the fixed point invisible.


I think that is much easier that to use scripting!

© 2023 International GeoGebra Institute