# Toggle show / drag properties in script

**URL:** <https://cl.desmos.com/t/toggle-show-drag-properties-in-script/1663>\
**Category:** Questions\
**Created:** [October 8, 2020, 8:40pm UTC](https://cl.desmos.com/t/toggle-show-drag-properties-in-script/1663 "2020-10-08T20:40:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lydia\_Nevin](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/lydia_nevin/32/1289_2.png) [@Lydia\_Nevin](https://cl.desmos.com/u/Lydia_Nevin)\
**Post date:** [October 8, 2020, 8:40pm UTC](https://cl.desmos.com/t/toggle-show-drag-properties-in-script/1663/1 "2020-10-08T20:40:14Z")

</div>

I’m wondering if there’s any way to change whether a point on a graph is draggable from within a script. For example, to “lock in” a draggable point when a student presses a button or chooses a certain answer in a checklist.

It would also be nice to be able to toggle whether something in the expression list is shown or hidden, or turn on/off the animations that you set in the expression list.

I don’t see sinks listed for this in the documentation so maybe it’s not currently implemented. If anyone has an idea for a workaround that would be cool.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [October 8, 2020, 9:13pm UTC](https://cl.desmos.com/t/toggle-show-drag-properties-in-script/1663/2 "2020-10-08T21:13:14Z")

</div>

Expressions are easy to toggle. Just have a variable that will change based on your button press. Then, use that as a restriction, just as you would restrict domain for a function.

For example, in graph CL:

```auto
p=button.pressCount
number("p"): numericValue("\mod(${p},2)")

```

In graph, this function would start displayed, then toggle on/off with the button press.

```auto
f(x)=3x+5 {p=0}

```

---

<div class="post-metadata">

**Author:** ![Lydia\_Nevin](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/lydia_nevin/32/1289_2.png) [@Lydia\_Nevin](https://cl.desmos.com/u/Lydia_Nevin)\
**Post date:** [October 8, 2020, 9:18pm UTC](https://cl.desmos.com/t/toggle-show-drag-properties-in-script/1663/3 "2020-10-08T21:18:09Z")

</div>

Ok thank you, that’s very helpful!

Do you have any suggestions for the dragging thing? You can make a point draggable using 2 numbers with sliders, and then set those numbers in the script as well to prevent the dragging. But a “when” always needs an “otherwise” so is there a way to only set a value for a number when a certain condition is met, and otherwise let it be defined by the slider (that the students can’t see)?

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [October 8, 2020, 9:27pm UTC](https://cl.desmos.com/t/toggle-show-drag-properties-in-script/1663/4 "2020-10-08T21:27:49Z")

</div>

Just did a quick search. The work around for points is to use sliders for the coordinates (say (x\_P,y\_P) ), as well as for the bounds of the slider (e.g. (x\_1\<=x\_P\<=x\_2)). Then, capture the coordinates when the button press and set the upper and lower bounds of the slider to those values.

In button CL, for :

```auto
capture("x_P"): graph.number("x_P")
capture("y_P): graph.number("_P")

```

In graph CL (similar for y):

```auto
number("x_1"): when button.pressCount>0 button.lastValue("x_P")
                         otherwise -10 #or whatever you want
number("x_2"): when button.pressCount>0 button.lastValue("x_P")
                         otherwise 10

```

You could reenable draggability with more conditions.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [October 8, 2020, 9:33pm UTC](https://cl.desmos.com/t/toggle-show-drag-properties-in-script/1663/5 "2020-10-08T21:33:26Z")

</div>

You can also put restrictions next to a coordinate as you would with a function, but it will lock that number (unless it’s a function linked to the other coordinate’s slider).

`A=(x_1,y_1 {p=0})` can be dragged left to right and toggled as with the function, but `y_1` would be locked.

---

<div class="post-metadata">

**Author:** ![Lydia\_Nevin](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/lydia_nevin/32/1289_2.png) [@Lydia\_Nevin](https://cl.desmos.com/u/Lydia_Nevin)\
**Post date:** [October 8, 2020, 9:38pm UTC](https://cl.desmos.com/t/toggle-show-drag-properties-in-script/1663/6 "2020-10-08T21:38:47Z")

</div>

This is great, thanks! I didn’t know you could set slider bounds to variables but that’s good to know in general too.

I just tried what you said in your other reply and ran into the same thing. I wish that we just had sinks for these things, it would be a lot easier.
