Interface variables - sliders affecting sliders - interface

Let's say I have two sliders on my interface. Slider one goes from 0-500 and slider two goes from 0-100.
Is there anyway of setting it so that the value of slider one influences the possible values for slider two. So if I set slider one to 500, slider two can only be values from 0-30, for example.
Alternatively it would not necessarily have to be a slider affecting another slier, it could be a button. So if I have buttons A and B, if I select A the slider can be 0-10 but if I select B only 20-50.
Bit of a strange query I admit, I've just been tasked with making an interactive "model" for kids to try out different systems.
Thanks for taking the time to read this.

Yes, you can do this. Example: make 3 sliders: test0, test1, test2. Let the min and max values of test0 be test1 and test2. Let the min and max values of test1 be 0 and 5, and set a value of 1. Let the min and max values of test2 be 95 and 100, and set a value of 99. Your test0 slider will now work as hoped.
BUT what happens if you make the min and max values of test0 to test2 and test1? OK, you get odd behavior, which is likely to look broken to your "kids". So ... this arrangement is not a good one. If you describe your goals in more details, maybe we can find a better solution.

Related

Map step to linear scale more than 100 with MUI Slider

I'm using MUI slider, and I'm at a loss how to create a slider with mapping for values more than 100. Apart from creating all 180 days in the mark array and restricting the values, is there another way to do it? I was hoping to be able to set something like step={1} and stepLength={100/180} which will give the distance travelled on the line per step (signifying one day).
I have this codesandbox with my not-working-correctly example.
Just had this same problem. Add
max={180}
In your
<Slider
...
min={0}
max={180}
...
/>
Then change the values under your labels inside of
const Marks = [...];
To get your desired output!
If you want to add a side button to increment by a certain amount, MUI also has an input field option.

How to make the set of possible values for UISlider an open interval?

I am using a UISlider to allow a user to choose among four options. I ask the user a question of the form "how much do you like this thing?", they respond by moving the slider, and then behind the scenes I map the value of the slider to one of four elements of an array. I want the first quarter of the slider to correspond to the first element of the array, the second quarter of the slider to correspond to the second element of the array, and so on.
By default, the range of a slider is [0,1], so one natural way to do what I want is:
let index = Int(rangedSlider.value * Float(currentAnswers.count) )
assuming that rangedSlider is the name of the outlet connected to the UISlider in question, and currentAnswers is the array of answers I'm mapping to. The issue with this is that if the user moves the slider all the way to the right, that sets the value of the slider to 1, which maps to index 4 by the formula above (assuming there are four answers). I can always add an additional line of code that takes care of that case separately,
if rangedSlider.value == 1 { index = currentAnswers.count - 1 }
but I prefer a one line solution.
I can also set the max value of the slider to 0.99 in the Storyboard and stick with the first line of code I wrote, but I want to know: is there a built-in way to make the range of UISlider values an open interval? Is there a better way to get the behavior I want?
Is this any more complicated than:
let index = Int(rangedSlider.value * Float(currentAnswers.count - 1))
Or have I misunderstood the problem you're having?
That way your index will be returned as a number between 0 and 3 with 0 corresponding to the first answer and 3 corresponding to the fourth answer.

Is there a way to set the amount a sliders value changes when you use it?

I'm am trying to make it so that when you interact with a slider, it goes up or down by 5. I know you can make it go up in whole numbers but can you change the base value that it increases/decreases by?
Not a built-in feature unfortunately. The workaround is to enable Whole Numbers, and set:
Slider min = Actual min / Step
Slider max = Actual max / Step
Then in your code you can do Actual value = Slider value * Step
Or you can write your own slider component with stepping support.
PS: I know, it sucks.

Linking sliders in Netlogo so their cumulative value always remains 100% or less

I looked but could not locate any Netlogo code that links a set of sliders that, as one increases in value the other sliders decrease so the total value never exceeds 100% (even though the total can be less than 100%). Has anyone ever tried this?
Thanks
Rudy
You could implement it with something like an 'Update sliders' button, where you set the values you want for all the variables, then press the button and that calls a procedure to adjust them all so they add to no more than 100%. But sliders adjust either because the user adjusts them, or the NetLogo code says something like set variable-name new-value and that code is called in some way.
In practice, if I have multiple sliders that I don't want the total to exceed something, then I have a line at the start of the go procedure that checks the total and stops with a message if it's too high.

how to fix interval on UISlider,iphone

I have Slider,which works perfect.
But what i am trying to do is,
for ex, min =0 and max=50 and x=0
every time i slide or use buttons to change the value of slider, the interval should be of 5 only.
i.e x should be equal to only 0,5,10,15.....50
Suggestions.
Thanks
In the callback (value changed) - read the value, round it up or down to the nearest increment of 5, then set the slider to your preferred value. That way, it will 'jump' between your preferred values.