Slider Issues

Hey,

first of all thanks for this cool GUI system!
It’s really easy to get into, but sometimes little issues pop up - please don’t stop updating it :slight_smile:

Ok, so now to my problem:
I’ve created and added a vertical Slider to a Window. I also added an appropriate onChange event.
Then I want to set the slider to some initial value using setSelectedIndexWithCallback.
The event is triggered, but the button on the slider does not move to the new position, it stays at the bottom!
I noticed the same when you click on the slider bar: the event is triggered with a value in the direction where you clicked, but the button doesn’t move.

Here is some code:

Slider slider = new Slider(screen, new Vector2f(30, 70), new Vector2f(25, 150), Element.Orientation.VERTICAL, false)
{
  @Override
  public void onChange(int selectedIndex, Object value)
  {
    System.out.println("selected = " + selectedIndex);
  }
};
window.addChild(slider);
slider.setSelectedIndexWithCallback(50);

Am I missing something?

So I can test this properly, how are you calling the event to update the slider?

I’m doing this in the initialization of an app state and there is nothing more I do to the slider instance after that.
The onChange event is called automatically (as I thought it is supposed to be).

But I managed to fix it! I just had to set the slider step range like this:

slider.setStepFloatRange(1.0f, 10.0f, 0.1f);

I think it would be useful if the Slider class had a default range set, maybe like this:

slider.setStepIntegerRange(0, 100, 1);

After that you can set the selected index or value without issues and even the clicking on the bar has the expected effect.