User avatar
BA_DeclanRogers
Topic Author
Posts: 6
Joined: 23 Apr 2024, 01:16
Location: Melbourne, Australia
Contact:

Slider With Acceleration

29 Jan 2026, 06:18

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!
Declan Rogers
Lead UI Programmer @ Big Ant Studios
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: Slider With Acceleration

30 Jan 2026, 17:17

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.
public SliderAccelerationBehavior: public BehaviorT<Slider> { ... };
<Slider ...>
  <b:Interaction.Behaviors>
    <local:SliderAccelerationBehavior .../>
  </b:Interaction.Behaviors>
</Slider>
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.
 
User avatar
BA_DeclanRogers
Topic Author
Posts: 6
Joined: 23 Apr 2024, 01:16
Location: Melbourne, Australia
Contact:

Re: Slider With Acceleration

04 Feb 2026, 22:47

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!!
Declan Rogers
Lead UI Programmer @ Big Ant Studios
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: Slider With Acceleration

05 Feb 2026, 17:06

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!
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.
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.
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.

Who is online

Users browsing this forum: Bing [Bot] and 4 guests