Export to GitHub

controlp5 - issue #47

Slider values are clamped at 100 (default max range?) during initialization


Posted on May 5, 2012 by Massive Wombat

What steps will reproduce the problem? 1. Run the test example below. 2. The only way to set the value is by hardcoding it in a setValue call.

--[ EXAMPLE SKETCH BEGIN]---

import controlP5.*; ControlP5 cp5;

int sliderValueOne = 211; int sliderValueTwo = 222;

void setup() { size(300, 150); cp5 = new ControlP5(this); print("I used to be " + sliderValueOne); cp5.addSlider("sliderValueOne").setPosition(75, 50).setRange(0, 255).setValue(sliderValueOne); cp5.addSlider("sliderValueTwo").setPosition(75, 90).setRange(0, 255).setValue(144).setValue(sliderValueTwo); println(", but I got capped at " + sliderValueOne); noStroke(); }

void draw() { background(sliderValueOne); fill(sliderValueTwo); rect(25, 25, width-50, height-50); }

--[ EXAMPLE SKETCH END]---

What is the expected output? What do you see instead?

The expected output is that the Sliders are automatically set to their actual initial values, 211 and 222 respectively. However it seems they are clamped at the default max range 100. Even when manually using setValue after setRange, it is still not possible to set the Sliders to the variable's value. In fact the variable's original value is clamped as a result. See the first Slider. The only way to set a Slider above 100 is by using setValue() with a hardcoded value. See the second Slider.

What version of the product are you using? On what operating system?

Window XP + Processing 1.5.1 + ControlP5 0.7.2

Please provide any additional information below.

Other than that, controlP5 is still awesome ;-)

Comment #1

Posted on May 15, 2012 by Happy Hippo

ok, reproduced and fixed with next release (0.7.3)

Comment #2

Posted on May 15, 2012 by Happy Rhino

(No comment was entered for this change.)

Comment #3

Posted on May 18, 2012 by Happy Rhino

(No comment was entered for this change.)

Comment #4

Posted on May 22, 2012 by Massive Wombat

Andreas, thanks for fixing this. I tested the new release 0.7.3. and saw that it worked. However in my app it didn't work. I tracked down the problem. If you call setSize() BEFORE setRange() the value is still capped to 100. If you call setSize() AFTER setRange all is well. See the example code below. Of course re-ordering the calls is no problem, so I have adapted this in my app. However I thought I should let you know, because there is still some involuntary capping going on somewhere. :D

--[ EXAMPLE SKETCH BEGIN]---

import controlP5.*; ControlP5 cp5;

int sliderValueOne = 211; int sliderValueTwo = 222;

void setup() { size(300, 150); cp5 = new ControlP5(this); cp5.addSlider("sliderValueOne").setSize(75, 9).setPosition(75, 50).setRange(0, 255); cp5.addSlider("sliderValueTwo").setPosition(75, 90).setRange(0, 255).setSize(75, 9); noStroke(); }

void draw() { background(sliderValueOne); fill(sliderValueTwo); rect(25, 25, width-50, height-50); }

--[ EXAMPLE SKETCH END]---

Status: Fixed

Labels:
Type-Defect Priority-Medium