Connect Slider Value
-
How can I link a slider's value to a label to display the value there?
Thanks! -
@voxuer1 You need to do this through scripting. In your slider's control callback you can set the text property of the label.
-
Examples of how to access LAF (Look and feel) functions are in this video. If you know anything about scripting im sure you can figure it out how to push the value of the slider into the item that the text object will be looking for to display. Thats my version of code talk. lol. I have no idea how to script and learned how to do that from this video. Thats all.
Here you go.
-
@Chazrox Thanx!
-
-
LAF (Look and feel) functions
**Paint Routines
-
@d-healey After hours of watching YouTube tutorials, I've found a solution to link a label value to a slider, yeh, but there's just a small problem left that I can't fix. I want to round the value to 2 decimal places, which works, but sometimes I get values with more than 10 decimal places. Hmm, can you tell me what's wrong with my script?
const var Speed = Content.getComponent("Speed");
const var SpeedValue = Content.getComponent("SpeedValue");inline function onSpeedControl(component, value)
{
local roundedValue = Math.floor(value * 100 + 0.5) / 100;
SpeedValue.set("text", roundedValue);
Console.print("Slider Value: " + roundedValue);
};Content.getComponent("Speed").setControlCallback(onSpeedControl);
-
@voxuer1 you could use the double to string function and specify how many digits you want
-
@mmprod yes that´s it thanks
-
@voxuer1 working code
const var Speed = Content.getComponent("Speed");
const var SpeedValue = Content.getComponent("SpeedValue");inline function onSpeedControl(component, value)
{
local formattedValue = Engine.doubleToString(value, 2);
SpeedValue.set("text", formattedValue);
Console.print("Slider Value: " + formattedValue);
};Content.getComponent("Speed").setControlCallback(onSpeedControl);