[fixed] Restrict range of InputBox input

melbapplets shared this problem 5 years ago
New

Hello,


In earlier versions, you could restrict the range of acceptable input for a (numeric) input box as follows:

1. create a slider for a number n and set the min, max values for the slider

2. create an input box for n: InputBox[n]


Then, any input typed into the textbox will be restricted to the range [min, max]. If the user enters something outside this range, it gets 'clamped' to min/max.


It seems that this behaviour has changed in recent versions - now if the user types an input out of the slider's range, the min, max settings for the slider get increased. I notice it's also possible to input a non-integer value for an integer slider.


Is there an easy way to restore the previous behaviour? A few of my applets were relying on it. If not, I could use scripting to enforce the ranges, but that's not as maintainable...


Thanks

Anthony

Comments (5)

photo
1

hi

you can something like this, using a nested condition:

input=If[n<min, min, If[n>max, max, n]]

fb8296173b42b0708be64177e331e65b

https://ggbm.at/1576837

photo
1

An added problem.


If you create

    min=0

    max=15

and use these for the slider's min and max settings, then a value of 20 in the input box changes these values back to numbers.


Setting the slider as fixed makes no difference.


Simon

photo
1

Thanks, fixed for next release

photo
1

It still changes if the input is an unexpected out of range number.

photo
photo
1

Thanks for another quick fix! :)

© 2021 International GeoGebra Institute