Discrete DirectScrollBar

Is there a way to force a DirectScrollBar to only allow discrete values, for example the integer number in a given range, and not let the cursor to stay between two of the allowed values ?

I need something like that either to select an integer value for a configuration parameter, or to select an enum value. (I could use a DirectScrolledList, but I prefer the look of an actual scroll bar :slight_smile: )

Forcing a DirectScrollBar to use integers rather than float is not directly possible.

You could simply implement this by creating a new class derived by DirectScrollBar and create a function, that will automatically round and set the active value to the next best integer when the thumb button is released.
In addition to that, just make sure to set the range, scrollSize and pageSize to some fitting integer values.
If the numbers get too high, you may also want to manually set the thumb width (frameSize index 0 and 1) and resizeThumb to False.

1 Like