-
-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Expected Behavior
When the pos
property of a <slider>
within a <sidebar>
is set via code, both the background blue graphic and the selection cursor on the slider should move (or expand/shrink in the background's case) to match the new value.
Current Behavior
The background of the slider changes to show the new value, but the selection cursor on the slider resets position to 0.
Steps to Reproduce (for bugs)
- Create a
<slider>
within a<sidebar>
and add it to the state - Set the
onChange
function of the slider to update a variable containing, for example, volume for music - Set the
pos
property of the slider once the sidebar has been shown via.show()
Media
hl_01Ex5y5JnG.mp4
Test app / minimal test case
PlayState.hx:
package;
import flixel.FlxG;
import flixel.FlxState;
import haxe.ui.Toolkit;
import haxe.ui.containers.SideBar;
class PlayState extends FlxState
{
var gameVolume = 0.5;
var mainView:MainView;
override public function create()
{
super.create();
Toolkit.init();
Toolkit.autoScale = false;
mainView = new MainView();
mainView.setPosition(0, 0);
add(mainView);
mainView.mySlider.onChange = (_) ->
{
gameVolume = mainView.mySlider.value / 100;
}
}
override public function update(elapsed:Float)
{
super.update(elapsed);
if (FlxG.keys.anyJustPressed([SPACE]))
{
if (mainView.hidden)
{
mainView.show();
mainView.mySlider.pos = gameVolume * 100;
}
else
mainView.hide();
}
}
}
@:build(haxe.ui.macros.ComponentMacros.build("assets/ui/sliderTest.xml"))
class MainView extends SideBar
{
override public function new()
{
super();
// mySlider.pos = 30;
}
}
sliderTest.xml:
<?xml version="1.0" encoding="UTF-8"?>
<sidebar width="200px" height="100%">
<vbox width="100%" height="100%">
<slider id="mySlider" width="100px" step="10" majorTicks="20" minorTicks="10" />
</vbox>
</sidebar>
Context
Trying to keep my game's music volume in a variable and set the slider to the right position when the sidebar menu is hidden and shown.
Your Environment
- HaxeFlixel 4.11.0
- Lime 7.9.0
- OpenFL 9.1.0
- haxeui-core [git]
- haxeui-flixel [git]
- Windows 10 21H2
- HashLink 1.11, Windows MSVC, HTML5
Metadata
Metadata
Assignees
Labels
No labels