-
- BA_DeclanRogers
- Posts: 6
- Joined:
- Location: Melbourne, Australia
- Contact:
Slider With Acceleration
Hey all,
We're currently attempting to write a custom slider that accelerates the rate at which the selected value changes based on how long the user has been pressing left or right on the controller or keyboard. We want it to still be functional as a regular slider with full mouse support. Is this possible? What's the best way to achieve this?
Thank you for your support!
We're currently attempting to write a custom slider that accelerates the rate at which the selected value changes based on how long the user has been pressing left or right on the controller or keyboard. We want it to still be functional as a regular slider with full mouse support. Is this possible? What's the best way to achieve this?
Thank you for your support!
Declan Rogers
Lead UI Programmer @ Big Ant Studios
Lead UI Programmer @ Big Ant Studios
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Slider With Acceleration
Hello,
Creating a behavior would be a good solution for this, because you can hook to the PreviewKeyDown/Up events to calculate the value change yourself, and then mark the event as handled to avoid the Slider logic.
You can also define the behavior as part of your Slider default style if you want to apply it to all sliders.
Please let us know if you need more guidance on how to create such a behavior.
Creating a behavior would be a good solution for this, because you can hook to the PreviewKeyDown/Up events to calculate the value change yourself, and then mark the event as handled to avoid the Slider logic.
Code: Select all
public SliderAccelerationBehavior: public BehaviorT<Slider> { ... };Code: Select all
<Slider ...>
<b:Interaction.Behaviors>
<local:SliderAccelerationBehavior .../>
</b:Interaction.Behaviors>
</Slider>Please let us know if you need more guidance on how to create such a behavior.
-
- BA_DeclanRogers
- Posts: 6
- Joined:
- Location: Melbourne, Australia
- Contact:
Re: Slider With Acceleration
Hey All,
Thank you for your quick resoponse.
We have taken control over the PreviewKeyUp/Down and using the amount of frames it is held down for to increment the slider. (I would like the use the DT but I was unable to find a way to access it)
If there is a better way please let us know!
Another question very closely adjacent to this; I am also working on a 2D slider (X, Y). Is there an event I should look at for Analog Stick position with the stick position value? I would like a smooth positioning with the stick; currently it's quite jumpy.
Thank you for your support!!
Thank you for your quick resoponse.
We have taken control over the PreviewKeyUp/Down and using the amount of frames it is held down for to increment the slider. (I would like the use the DT but I was unable to find a way to access it)
If there is a better way please let us know!
Another question very closely adjacent to this; I am also working on a 2D slider (X, Y). Is there an event I should look at for Analog Stick position with the stick position value? I would like a smooth positioning with the stick; currently it's quite jumpy.
Thank you for your support!!
Declan Rogers
Lead UI Programmer @ Big Ant Studios
Lead UI Programmer @ Big Ant Studios
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Slider With Acceleration
I recommend you store the time (we expose a HighResTimer in case you need it) and make the increments independant of the framerate and based on time instead, calculating the time passed since the initial KeyDown, and subsequent KeyDown events.We have taken control over the PreviewKeyUp/Down and using the amount of frames it is held down for to increment the slider. (I would like the use the DT but I was unable to find a way to access it). If there is a better way please let us know!
You can use IView's Scroll() and HScroll() to inject gamepad's stick position. Those are translated to MouseWheel events that your slider can use to update its value in a smooth way.Another question very closely adjacent to this; I am also working on a 2D slider (X, Y). Is there an event I should look at for Analog Stick position with the stick position value? I would like a smooth positioning with the stick; currently it's quite jumpy.
Who is online
Users browsing this forum: Bing [Bot] and 4 guests