DirectSlider can not work with low pageSize [SOLVED]

Hi,

I have some strange behaviour with DirectSlider. If I use ‘too small’ pageSize (0.01 or 0.001 …) it does not move the slider and does not give correct value.

import direct.directbase.DirectStart
from direct.gui.DirectGui import *

def showValue():
    print slider['value']

slider = DirectSlider(range=(1,10), value=2, pageSize=.01, command=showValue)
print 'scrollSize:%s' %slider['scrollSize']

run()

When clicking on the right or left side of the thumb it still reports 2, but not 2.01, 2.02.
Of course 2.01 is ideal case which I know will be actually something like 2.0987 - I’m not looking such precision.
I tried to make the range small too, so the pageSize actually could move the thumb, but it didn’t help.
I use Panda3D 1.7.2 on Ubuntu x64.
I thought it was some float precision problem, but could not find the source to test it. I guess the real work is made by PGItem which is C code, I think.
Is this a bug or it is not expected to work with small pageSizes ?

The DirectSlider does require that the pageSize be larger than the scrollSize. The default scrollSize is 0.01, so you should set it to something smaller if you also want the pageSize to be so very small.

David

Thanks David.

Correct as always :slight_smile: