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