Forcing state on a DirectButton


I have a DirectButton that has custom geometry defined for the normal, rollover, and clicked states. In response to clicking the button, the NodePath containing the button is hidden (it acts like a contextual menu).

When I later reveal the NodePath again, the button I clicked earlier is still in the rollover state. I assume this is probaby because since the button was hidden when it was clicked, it wasn’t available to be tested for the mouse rolling away from it, so the engine never had a chance to set the state back to normal.

Is there a way to force the button’s state to normal once it is clicked?

Thank you for you help!


Hmm, that sounds like a bug. It’s supposed to realize that it’s not being rendered anymore and handle its state appropriately. I’ll look into it.


Thank you for the help!

I didn’t mention it previously, but I’m actually hiding a several-levels-removed parent of the Direct Button (i.e. hidingNode->interfaceNode->buttonSetNode->buttonThatWillNotUnhilite); I’m not sure if that makes a difference.

It might actually be useful to extend the interface on buttons to allow for explicit control of the implicit state system. Doing so would allow me to get several effects, including flashing the button if, for example, the return key is pressed in a text field that has a confirmation button. I was planning to do something to that effect, but I wasn’t able to figure out how the button’s implicit state switching works. Can anyone point me to the class or source file where the implicit state switching is handled?

Take care,

The implicit state switching is handled way down in the C++ level, in panda/src/pgui/pgButton.cxx.