Styling sliders and a possible bug?

Hey there,

so i got a few questions concerning Sliders.

  1. Styling sliders via a style.groovy should work according to the documentation, did it like described but it seems like nothing is happening.
    The code:
private Container mouseContainer(){
        final Container mouseContainer = new Container();
        final Label mouseXText = new Label(BUNDLE.getString("option.mouseXAxis"), "doom");
        mouseXText.setFontSize(FontSizes.OPTIONS.getSize());
        final Slider mouseX = new Slider("doom");
        final Label mouseYText = new Label(BUNDLE.getString("option.mouseYAxis"), "doom");
        mouseYText.setFontSize(FontSizes.OPTIONS.getSize());
        final Slider mouseY = new Slider("doom");


        mouseContainer.addChild(mouseXText);
        mouseContainer.addChild(mouseX);
        mouseContainer.addChild(mouseYText);
        mouseContainer.addChild(mouseY);

        return mouseContainer;

    }

The .groovy:

selector("slider.left.button", "doom"){
    color = color(0.4, 0.45, 0.5, 0.85f)
}

selector("slider.right.button", "doom"){
    color = color(0.4, 0.45, 0.5, 0.85f)
}

selector("slider.range", "doom"){
    color = color(1,1,1,1)
}

I believe this it he intended way to style them.
Ingame it looks like this:
image

Possible bug?
Another thing i have noticed is the missing + at the right side to increment my slider. I initally thought that i cut the slider of inside the container. Played around with it and couldn’t fix the issue. I can only assume that it has to to something with the class itself since i am basically using the default constructor. But maybe i am missing something.

Thanks for the help guys.

Since your slider has the glass styling, I’m guessing you either forked the existing glass style or something else.

Either way, your problem is in the code that I can’t see. Somehow your slider is using the glass styling and has somehow wiped out the label of the “right” button.

From the glass style:

…which you can see is not setting it any differently than yours. But if you have two of the exact same selector in your .groovy file then I’m not sure which one wins in this case.

As I said, the problem is in the parts that I can’t see.

1 Like

Well turns out you are 100% right. I messed up the groovy and it turned out it was already there so “standard” one got loaded. Thanks for the small hint with a big effect.

1 Like