DirectSlider - thumb

Goodnight everyone.

I’m having strange behavior on the thumb button of the DirectSlider control. When I have the mouse positioned over the thumb button and I try to update its position from another call (control-5), the thumb button does not move.
Does the DirectSlider control have any restrictions?

I hope you can help me.
Thanks!

from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import DirectSlider, DGG

base = ShowBase()
slider = DirectSlider(value=0.95)
slider.reparentTo(aspect2d)

def slider_adjust(*args):
    slider.setValue(0.1)

base.accept('control-5', slider_adjust)
base.run()

This is a bug in Panda. If the mouse is hovering over the thumb button, the underlying control PGSliderBar recognizes it as being pressed/held down according to is_button_down.
This method is used as a check function within set_ratio which is initially called by set_value to see if the value can be set or not.

1 Like

There is a solution.

from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import DirectSlider, DGG

base = ShowBase()
slider = DirectSlider(value=0.95)
slider['thumb_state'] = 'DISABLED'
slider.reparentTo(aspect2d)

def slider_adjust(*args):
    slider.setValue(0.1)

base.accept('control-5', slider_adjust)
base.run()
1 Like

A modification to the above might be to set the thumb’s state at the start of “slider_adjust”, thus allowing one to re-set it at the end of that method. This might–I haven’t tested it–result in a thumb that can be used as per normal and that can nevertheless be set via the method.

1 Like

Good afternoon, thanks for the ideas you shared with me. Based on them I did some tests and I put together their ideas that resulted in the following code.

For some reason panda takes some time to disable the thumb button of the slider, I imagine that some additional task is being performed by panda. This is the reason why I used a task. I needed to preserve the thumb button events (over, click, etc …)

Thanks for the help and I hope in the future panda3d can correct this functionality.

from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import DirectSlider, DGG

base = ShowBase()

slider = DirectSlider(value=0.95, thumb_frameColor=((1,1,1,1),(0.12,0.32,0.12546,1.0)))
slider.reparentTo(aspect2d)

def __slider_task(task):
    slider.setValue(0.1)
    slider["thumb_state"] = DGG.NORMAL
    return task.done

def slider_adjust(*args):
    slider["thumb_state"] = DGG.DISABLED
    taskMgr.doMethodLater(0.1, __slider_task, "slidertask")

base.accept('control-5', slider_adjust)
base.run()
1 Like

@logan have you opened a bug report for the initial behavior on github? If not, I can open up one sometime later. Otherwise, this bug may not get fixed but forgotten.

I don’t know how to register it on panda3d’s github. Is there a section to be able to add it to the github?

Thanks!

excellent, thanks for sharing the github link with me.

This is the report.