Stepper or Slider Maximum Value

Hi,

I have a challenge in that as the user drags an object I need to increment the maximumvalue of a stepper or a slider.  It looks like neither of the 2.0 widgets let this happen.  Would I delete the stepper and then re-add it with a new maximum value or do I have to write my own widget?

Any help greatly appreciated, Greg

Hi Greg,

Some of this may be possible with a little extra effort. On the Stepper, the maximum value is not “directly accessible” but, digging a bit deeper, you can reset the maximum value post-creation with this code:

[lua]

newStepper._view._maximumValue = 6

[/lua]

That will change the max value and make the Stepper stop at that value, versus the previous one. However, you may face issues if the Stepper is (for example) previously set at a higher value like 10, then you try to reduce it to 6. In that case, I doubt the Stepper will visually update to reflect that they can’t press in that direction any further.

On Slider, the current position is just based on a percentage of the width of the widget. So, you could probably just manually set the value/position of the slider handle with this:

[lua]

mySlider:setValue( percentage )

[/lua]

And that percentage would be calculated (by you) to be the “new percentage” based on the difference between the new value and the increased value.

Hope this helps,

Brent Sorrentino

Hi Brent,

Thanks for the ideas!   I’ll try setting the _view._maximumValue at runtime and see how that works.  

With the slider I am trying to use it as a fast forward and rewind based on a counter, so I will need to convert the widget from a percentage to a min/max/current value control.  The maximum value will always increment at run time as the user drags objects, the scaling of the button will obviously change based on the current value to maximum value ratio. 

I downloaded the widget framework to see how far I can get with customizing the control.

Thanks again, Greg

Hi Greg,

Some of this may be possible with a little extra effort. On the Stepper, the maximum value is not “directly accessible” but, digging a bit deeper, you can reset the maximum value post-creation with this code:

[lua]

newStepper._view._maximumValue = 6

[/lua]

That will change the max value and make the Stepper stop at that value, versus the previous one. However, you may face issues if the Stepper is (for example) previously set at a higher value like 10, then you try to reduce it to 6. In that case, I doubt the Stepper will visually update to reflect that they can’t press in that direction any further.

On Slider, the current position is just based on a percentage of the width of the widget. So, you could probably just manually set the value/position of the slider handle with this:

[lua]

mySlider:setValue( percentage )

[/lua]

And that percentage would be calculated (by you) to be the “new percentage” based on the difference between the new value and the increased value.

Hope this helps,

Brent Sorrentino

Hi Brent,

Thanks for the ideas!   I’ll try setting the _view._maximumValue at runtime and see how that works.  

With the slider I am trying to use it as a fast forward and rewind based on a counter, so I will need to convert the widget from a percentage to a min/max/current value control.  The maximum value will always increment at run time as the user drags objects, the scaling of the button will obviously change based on the current value to maximum value ratio. 

I downloaded the widget framework to see how far I can get with customizing the control.

Thanks again, Greg